1
0
Fork 0
GPT4FREE/sqlchat/README.md
t.me/xtekky 85a1961b64 sqlchat
2023-04-22 14:08:19 +01:00

833 B

Example: sqlchat (use like openai pypi package)

# Import sqlchat
import sqlchat

# sqlchat.Completion.create
# sqlchat.StreamCompletion.create

[...]

Example Chatbot

messages = []

while True:
    user = input('you: ')

    sqlchat_cmpl = sqlchat.Completion.create(
        prompt   = user,
        messages = messages
    )

    print('gpt:', sqlchat_cmpl.completion.choices[0].text)
    
    messages.extend([
        {'role': 'user', 'content': user }, 
        {'role': 'assistant', 'content': sqlchat_cmpl.completion.choices[0].text}
    ])

Streaming Response:

for response in sqlchat.StreamCompletion.create(
    prompt   = 'write python code to reverse a string',
    messages = []):

    print(response.completion.choices[0].text)