-
-
Save ScottCampit/d403c7ef86fdc2fd6b07507b463f1e85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import openai | |
import streamlit as st | |
openai.api_key = os.environ["OPENAI_API_KEY"] | |
def generate_response(prompt:str, temperature:float=0.5, max_tokens:int=1500, engine='davinci'): | |
response = openai.Completion.create( | |
engine=engine, | |
prompt=prompt, | |
temperature=temperature, | |
max_tokens=max_tokens, | |
top_p=1, | |
frequency_penalty=0.3, | |
presence_penalty=0.3 | |
) | |
generated_text = response["choices"][0]["text"] | |
return generated_text | |
st.title("Chatbot Assistant") | |
prompt = st.text_input(label="Enter your message: ") | |
if prompt: | |
response = generate_response(prompt) | |
st.write("Chatbot:", response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment