mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-11 07:07:04 +03:00
add aiassist.site
This commit is contained in:
parent
74f949e099
commit
8449728aa3
19
gpt4free/aiassist/README.md
Normal file
19
gpt4free/aiassist/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
aiassist.site
|
||||
|
||||
### Example: `aiassist` <a name="example-assist></a>
|
||||
|
||||
```python
|
||||
import aiassist
|
||||
|
||||
question1 = "Who won the world series in 2020?"
|
||||
req = aiassist.Completion.create(prompt=question1)
|
||||
answer = req["text"]
|
||||
message_id = req["parentMessageId"]
|
||||
|
||||
question2 = "Where was it played?"
|
||||
req2 = aiassist.Completion.create(prompt=question2, parentMessageId=message_id)
|
||||
answer2 = req2["text"]
|
||||
|
||||
print(answer)
|
||||
print(answer2)
|
||||
```
|
34
gpt4free/aiassist/__init__.py
Normal file
34
gpt4free/aiassist/__init__.py
Normal file
@ -0,0 +1,34 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
|
||||
class Completion:
|
||||
@staticmethod
|
||||
def create(
|
||||
systemMessage: str = "You are a helpful assistant",
|
||||
prompt: str = "",
|
||||
parentMessageId: str = "",
|
||||
temperature: float = 0.8,
|
||||
top_p: float = 1,
|
||||
):
|
||||
json_data = {
|
||||
"prompt": prompt,
|
||||
"options": {"parentMessageId": parentMessageId},
|
||||
"systemMessage": systemMessage,
|
||||
"temperature": temperature,
|
||||
"top_p": top_p,
|
||||
}
|
||||
|
||||
url = "http://43.153.7.56:8080/api/chat-process"
|
||||
request = requests.post(url, json=json_data)
|
||||
content = request.content
|
||||
|
||||
response = Completion.__load_json(content)
|
||||
return response
|
||||
|
||||
@classmethod
|
||||
def __load_json(cls, content) -> dict:
|
||||
decode_content = str(content.decode("utf-8"))
|
||||
split = decode_content.rsplit("\n", 1)[1]
|
||||
to_json = json.loads(split)
|
||||
return to_json
|
Loading…
Reference in New Issue
Block a user