Comments (1)
seems the responses can be chunked. I had chatgpt help me with code to deal with chunked responses. Not sure if that is exactly what's happening with you but it helped me with incomplete or duplicate looking results. Note that I'm using 'answer' and not 'snippet' though:
`answer = perplexity.search(text)
full_answer = ""
last_chunk = ""
for item in answer:
if 'answer' in item and item['answer']:
current_chunk = item['answer']
if current_chunk.startswith(last_chunk):
new_content = current_chunk[len(last_chunk):]
full_answer += new_content
else:
full_answer += current_chunk
last_chunk = current_chunk
if 'final' in item and item['final']:
break
if full_answer:
print(textwrap.fill(full_answer, width=90))
else:
logging.error("No valid results found")`
from perplexityai.
Related Issues (20)
- Issues with deployment on Heroku HOT 3
- again json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) HOT 3
- Knowing which model was used in each prompt response/answer object
- JSONDecodeError error (running in Colab) HOT 4
- websocket error: Handshake status 400 Bad Request HOT 1
- i need your Help HOT 1
- websocket error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
- Labs API doesn't work
- rate limit?
- Failed to ask anonymous user again HOT 3
- Image
- Multiple sessions in parallel?
- Models used? HOT 3
- raise JSONDecodeError("Expecting value", s, err.value) from None
- can anyone solve this error HOT 2
- Using uploaded files
- Can not init Perplexity() HOT 4
- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perplexityai.