awacke1 commited on
Commit
9bfc205
·
1 Parent(s): e6aa461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -18
app.py CHANGED
@@ -1,17 +1,15 @@
1
  import streamlit as st
2
- from streamlit_chat import message
3
- # from utils import get_initial_message, get_chatgpt_response, update_chat
4
  import os
 
 
5
  from dotenv import load_dotenv
6
- load_dotenv()
7
- import openai
8
  from openai import ChatCompletion
9
 
 
 
10
  openai.api_key = os.getenv('OPENAI_KEY')
11
  # keys are here: https://platform.openai.com/auth/callback?code=ReZ4izEw0DwkUKrHR-Opxr5AMMgo9SojxC9pNHQUcjD6M&state=OGZFNDJmLlJGNlIwOUxlakpXZkVFfjNxNy02ZlFtLWN4eUcuOXJobXouSQ%3D%3D#
12
- # Read this, https://blog.futuresmart.ai/building-a-gpt-4-chatbot-using-chatgpt-api-and-streamlit-chat
13
-
14
-
15
 
16
  # Define a function to chat with the model
17
  def chat_with_model(prompts):
@@ -23,16 +21,8 @@ def chat_with_model(prompts):
23
  response = openai.ChatCompletion.create(model=model, messages=conversation)
24
  return response['choices'][0]['message']['content']
25
 
26
-
27
- import openai
28
- import streamlit as st
29
- from streamlit_chat import message
30
- import os
31
- from dotenv import load_dotenv
32
-
33
  load_dotenv('api_key.env')
34
 
35
-
36
  def generate_response(prompt):
37
  completion=openai.Completion.create(
38
  engine='text-davinci-003',
@@ -45,9 +35,6 @@ def generate_response(prompt):
45
  message=completion.choices[0].text
46
  return message
47
 
48
-
49
-
50
-
51
  # Streamlit App
52
  def main():
53
  st.title("Chat with AI")
 
1
  import streamlit as st
2
+ import openai
 
3
  import os
4
+
5
+ from streamlit_chat import message
6
  from dotenv import load_dotenv
 
 
7
  from openai import ChatCompletion
8
 
9
+ load_dotenv()
10
+
11
  openai.api_key = os.getenv('OPENAI_KEY')
12
  # keys are here: https://platform.openai.com/auth/callback?code=ReZ4izEw0DwkUKrHR-Opxr5AMMgo9SojxC9pNHQUcjD6M&state=OGZFNDJmLlJGNlIwOUxlakpXZkVFfjNxNy02ZlFtLWN4eUcuOXJobXouSQ%3D%3D#
 
 
 
13
 
14
  # Define a function to chat with the model
15
  def chat_with_model(prompts):
 
21
  response = openai.ChatCompletion.create(model=model, messages=conversation)
22
  return response['choices'][0]['message']['content']
23
 
 
 
 
 
 
 
 
24
  load_dotenv('api_key.env')
25
 
 
26
  def generate_response(prompt):
27
  completion=openai.Completion.create(
28
  engine='text-davinci-003',
 
35
  message=completion.choices[0].text
36
  return message
37
 
 
 
 
38
  # Streamlit App
39
  def main():
40
  st.title("Chat with AI")