Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,6 @@ import nltk
|
|
| 7 |
import openai
|
| 8 |
import time
|
| 9 |
|
| 10 |
-
|
| 11 |
import pip
|
| 12 |
import subprocess
|
| 13 |
import sys
|
|
@@ -19,13 +18,6 @@ subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requiremen
|
|
| 19 |
nltk.download('punkt')
|
| 20 |
nltk.download('all') # or any other packages your project depends on
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
# Put your OpenAI API key here
|
| 30 |
openai.api_key = os.getenv('OpenAPI')
|
| 31 |
|
|
@@ -36,8 +28,8 @@ def call_openai_api(text, user_prompt):
|
|
| 36 |
response = openai.ChatCompletion.create(
|
| 37 |
model="gpt-3.5-turbo",
|
| 38 |
messages=[
|
| 39 |
-
{"role": "system", "content": "You are a
|
| 40 |
-
{"role": "user", "content":
|
| 41 |
]
|
| 42 |
)
|
| 43 |
return response['choices'][0]['message']['content']
|
|
@@ -79,11 +71,11 @@ iface = gr.Interface(
|
|
| 79 |
fn=pdf_to_text,
|
| 80 |
inputs=[
|
| 81 |
gr.inputs.File(label="PDF File (Upload a Zip file containing ONLY PDF files)"),
|
| 82 |
-
gr.inputs.Textbox(label="User Prompt (Enter a prompt to
|
| 83 |
],
|
| 84 |
outputs=gr.outputs.Textbox(label="Cognitive Agent Response"),
|
| 85 |
title="Ask An Expert Proof Of Concept",
|
| 86 |
-
description="This app extracts knowledge from the uploaded Zip files.
|
| 87 |
)
|
| 88 |
iface.launch(share=False)
|
| 89 |
|
|
|
|
| 7 |
import openai
|
| 8 |
import time
|
| 9 |
|
|
|
|
| 10 |
import pip
|
| 11 |
import subprocess
|
| 12 |
import sys
|
|
|
|
| 18 |
nltk.download('punkt')
|
| 19 |
nltk.download('all') # or any other packages your project depends on
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# Put your OpenAI API key here
|
| 22 |
openai.api_key = os.getenv('OpenAPI')
|
| 23 |
|
|
|
|
| 28 |
response = openai.ChatCompletion.create(
|
| 29 |
model="gpt-3.5-turbo",
|
| 30 |
messages=[
|
| 31 |
+
{"role": "system", "content": f"You are a knowledgeable assistant with a persona based on this: \n{text}"},
|
| 32 |
+
{"role": "user", "content": user_prompt},
|
| 33 |
]
|
| 34 |
)
|
| 35 |
return response['choices'][0]['message']['content']
|
|
|
|
| 71 |
fn=pdf_to_text,
|
| 72 |
inputs=[
|
| 73 |
gr.inputs.File(label="PDF File (Upload a Zip file containing ONLY PDF files)"),
|
| 74 |
+
gr.inputs.Textbox(label="User Prompt (Enter a prompt to interact with your persona)")
|
| 75 |
],
|
| 76 |
outputs=gr.outputs.Textbox(label="Cognitive Agent Response"),
|
| 77 |
title="Ask An Expert Proof Of Concept",
|
| 78 |
+
description="This app extracts knowledge from the uploaded Zip files. The Cognitive Agent will use this data to build your unique persona."
|
| 79 |
)
|
| 80 |
iface.launch(share=False)
|
| 81 |
|