summaryrefslogtreecommitdiffstats
path: root/openaihosted/readme.md
blob: 7b8ced56658caf89b5f54ab82f4fc93446b6e286 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
### Example: `openaihosted` (use like openai pypi package) <a name="example-openaihosted"></a>

```python
import openaihosted

messages = [{"role": "system", "content": "You are a helpful assistant."}]
while True:
    question = input("Question: ")
    if question == "!stop":
        break

    messages.append({"role": "user", "content": question})
    request = openaihosted.Completion.create(messages=messages)

    response = request["responses"]
    messages.append({"role": "assistant", "content": response})
    print(f"Answer: {response}")
```