Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,25 +7,12 @@ from pypdf import PdfReader
|
|
7 |
import gradio as gr
|
8 |
from huggingface_hub import InferenceClient
|
9 |
|
10 |
-
load_dotenv(override=True)
|
11 |
-
|
12 |
-
"""
|
13 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
14 |
-
"""
|
15 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
16 |
|
17 |
|
18 |
class Harold:
|
19 |
|
20 |
def __init__(self):
|
21 |
-
|
22 |
-
self.name = "Harold"
|
23 |
-
reader = PdfReader("data/Living-Playbook.pdf")
|
24 |
-
self.text = ""
|
25 |
-
for page in reader.pages:
|
26 |
-
text = page.extract_text()
|
27 |
-
if text:
|
28 |
-
self.text += text
|
29 |
|
30 |
def system_prompt(self):
|
31 |
system_prompt = f"""
|
@@ -43,11 +30,8 @@ class Harold:
|
|
43 |
def chat(self, message, history):
|
44 |
messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
messages=messages,
|
49 |
-
)
|
50 |
-
return response.choices[0].message.content
|
51 |
|
52 |
|
53 |
if __name__ == "__main__":
|
|
|
7 |
import gradio as gr
|
8 |
from huggingface_hub import InferenceClient
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
class Harold:
|
13 |
|
14 |
def __init__(self):
|
15 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def system_prompt(self):
|
18 |
system_prompt = f"""
|
|
|
30 |
def chat(self, message, history):
|
31 |
messages = [{"role": "system", "content": self.system_prompt()}] + history + [{"role": "user", "content": message}]
|
32 |
|
33 |
+
|
34 |
+
return "hello"
|
|
|
|
|
|
|
35 |
|
36 |
|
37 |
if __name__ == "__main__":
|