Spaces:
Paused
Paused
fix client
Browse files
app.py
CHANGED
@@ -106,16 +106,19 @@ class ContextualQA:
|
|
106 |
self.client = None
|
107 |
|
108 |
|
109 |
-
client = anthropic.Client(api_key=os.environ["ANTHROPIC_API_KEY"])
|
110 |
-
|
111 |
-
|
112 |
def load_context(paper_id):
|
113 |
latex_source = download_arxiv_source(paper_id)
|
|
|
114 |
model = ContextualQA(client, model="claude-v1.3-100k")
|
115 |
model.load_text(latex_source)
|
116 |
return (
|
117 |
model,
|
118 |
-
[
|
|
|
|
|
|
|
|
|
|
|
119 |
)
|
120 |
|
121 |
|
@@ -125,6 +128,9 @@ def answer_fn(model, question, chat_history):
|
|
125 |
chat_history.append(("No Question Asked", "Please ask a question."))
|
126 |
return model, chat_history, ""
|
127 |
|
|
|
|
|
|
|
128 |
response = model.ask_question(question)
|
129 |
|
130 |
chat_history.append((question, response[0]["completion"]))
|
@@ -145,7 +151,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
145 |
|
146 |
with gr.Column():
|
147 |
with gr.Row():
|
148 |
-
paper_id_input = gr.Textbox(label="Enter Paper ID", value="
|
149 |
btn_load = gr.Button("Load Paper")
|
150 |
qa_model = gr.State()
|
151 |
|
|
|
106 |
self.client = None
|
107 |
|
108 |
|
|
|
|
|
|
|
109 |
def load_context(paper_id):
|
110 |
latex_source = download_arxiv_source(paper_id)
|
111 |
+
client = anthropic.Client(api_key=os.environ["ANTHROPIC_API_KEY"])
|
112 |
model = ContextualQA(client, model="claude-v1.3-100k")
|
113 |
model.load_text(latex_source)
|
114 |
return (
|
115 |
model,
|
116 |
+
[
|
117 |
+
(
|
118 |
+
f"Load the paper with id {paper_id}.",
|
119 |
+
"Paper loaded, You can now ask questions.",
|
120 |
+
)
|
121 |
+
],
|
122 |
)
|
123 |
|
124 |
|
|
|
128 |
chat_history.append(("No Question Asked", "Please ask a question."))
|
129 |
return model, chat_history, ""
|
130 |
|
131 |
+
client = anthropic.Client(api_key=os.environ["ANTHROPIC_API_KEY"])
|
132 |
+
model.client = client
|
133 |
+
|
134 |
response = model.ask_question(question)
|
135 |
|
136 |
chat_history.append((question, response[0]["completion"]))
|
|
|
151 |
|
152 |
with gr.Column():
|
153 |
with gr.Row():
|
154 |
+
paper_id_input = gr.Textbox(label="Enter Paper ID", value="2108.07258")
|
155 |
btn_load = gr.Button("Load Paper")
|
156 |
qa_model = gr.State()
|
157 |
|