Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import PyPDF2
|
| 3 |
-
import openai
|
| 4 |
import os
|
| 5 |
import keyfile
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# here we are calling our API for openAI
|
| 8 |
os.environ["OPENAI_API_KEY"] = keyfile.OPENAI_API_KEY
|
|
@@ -20,7 +22,7 @@ def extract_text(pdfPath):
|
|
| 20 |
def gptAnswer(prompt):
|
| 21 |
# I will try a request to GPT for answer the question
|
| 22 |
try:
|
| 23 |
-
resp =
|
| 24 |
model = "gpt-4o-mini",
|
| 25 |
messages = [
|
| 26 |
{"role" : "system", "content" : "You are helpful assistant."},
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import PyPDF2
|
|
|
|
| 3 |
import os
|
| 4 |
import keyfile
|
| 5 |
+
from openai import OpenAI
|
| 6 |
+
# Built a client for OpenAI
|
| 7 |
+
client = OpenAI()
|
| 8 |
|
| 9 |
# here we are calling our API for openAI
|
| 10 |
os.environ["OPENAI_API_KEY"] = keyfile.OPENAI_API_KEY
|
|
|
|
| 22 |
def gptAnswer(prompt):
|
| 23 |
# I will try a request to GPT for answer the question
|
| 24 |
try:
|
| 25 |
+
resp = client.chat.completions.create(
|
| 26 |
model = "gpt-4o-mini",
|
| 27 |
messages = [
|
| 28 |
{"role" : "system", "content" : "You are helpful assistant."},
|