2023-04-22 12:54:01 +00:00
|
|
|
### Example: `you` (use like openai pypi package) <a name="example-you"></a>
|
|
|
|
|
|
|
|
```python
|
2023-04-27 19:10:43 +00:00
|
|
|
|
|
|
|
from openai_rev import you
|
2023-04-22 12:54:01 +00:00
|
|
|
|
|
|
|
# simple request with links and details
|
|
|
|
response = you.Completion.create(
|
2023-04-26 18:20:18 +00:00
|
|
|
prompt="hello world",
|
|
|
|
detailed=True,
|
|
|
|
include_links=True, )
|
2023-04-22 12:54:01 +00:00
|
|
|
|
|
|
|
print(response)
|
|
|
|
|
|
|
|
# {
|
|
|
|
# "response": "...",
|
|
|
|
# "links": [...],
|
|
|
|
# "extra": {...},
|
|
|
|
# "slots": {...}
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
|
2023-04-26 18:20:18 +00:00
|
|
|
# chatbot
|
2023-04-22 12:54:01 +00:00
|
|
|
|
|
|
|
chat = []
|
|
|
|
|
|
|
|
while True:
|
|
|
|
prompt = input("You: ")
|
2023-04-26 18:20:18 +00:00
|
|
|
|
2023-04-22 12:54:01 +00:00
|
|
|
response = you.Completion.create(
|
2023-04-26 18:20:18 +00:00
|
|
|
prompt=prompt,
|
|
|
|
chat=chat)
|
|
|
|
|
2023-04-22 12:54:01 +00:00
|
|
|
print("Bot:", response["response"])
|
2023-04-26 18:20:18 +00:00
|
|
|
|
2023-04-22 12:54:01 +00:00
|
|
|
chat.append({"question": prompt, "answer": response["response"]})
|
|
|
|
```
|