rizam commited on
Commit
eb2dec4
1 Parent(s): 10f5dff

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +5 -12
  2. app.py +30 -0
  3. requirements.txt +5 -0
README.md CHANGED
@@ -1,13 +1,6 @@
1
- ---
2
- title: Gpt
3
- emoji: 📚
4
- colorFrom: purple
5
- colorTo: red
6
- sdk: streamlit
7
- sdk_version: 1.15.2
8
- app_file: app.py
9
- pinned: false
10
- license: agpl-3.0
11
- ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
+ # Welcome to Streamlit!
 
 
 
 
 
 
 
 
 
 
2
 
3
+ Edit `/streamlit_app.py` to customize this app to your heart's desire. :heart:
4
+
5
+ If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
6
+ forums](https://discuss.streamlit.io).
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import gradio as gr
4
+
5
+ #openai.api_key = "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"
6
+ #openai.api_key = "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"
7
+ openai.api_key ="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"
8
+ start_sequence = "\nAI:"
9
+ restart_sequence = "\nHuman: "
10
+
11
+ def predict(input,initial_prompt, history=[]):
12
+
13
+ s = list(sum(history, ()))
14
+ s.append(input)
15
+ # initial_prompt="The following is a conversation with an AI movie recommendation assistant. The assistant is helpful, creative, clever, and very friendly.Along with movie recommendation it also talks about general topics"
16
+ # \n\nHuman: Hello, who are you?\nAI: I am an AI created by OpenAI. How can I help you today?\nHuman: "
17
+ response = openai.Completion.create(
18
+ model="text-davinci-003",
19
+ prompt= initial_prompt + "\n" + str(s),
20
+ temperature=0.9,
21
+ max_tokens=150,
22
+ top_p=1,
23
+ frequency_penalty=0,
24
+ presence_penalty=0.6,
25
+ stop=[" Human:", " AI:"])
26
+ # tokenize the new input sentence
27
+ response2 = response["choices"][0]["text"]
28
+ history.append((input, response2))
29
+
30
+ return history, history
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ altair
2
+ pandas
3
+ streamlit
4
+ openai
5
+ gradio