Spaces:
Running
Running
updates per recrawl
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import re
|
|
7 |
from translate import Translator
|
8 |
|
9 |
|
10 |
-
from llama_index.indices.managed.vectara import VectaraIndex
|
11 |
from llama_index.core.agent import ReActAgent
|
12 |
from llama_index.llms.openai import OpenAI
|
13 |
from llama_index.core.tools import QueryEngineTool, ToolMetadata
|
@@ -28,9 +28,12 @@ def launch_bot():
|
|
28 |
vectara = VectaraIndex(vectara_api_key=cfg.api_key,
|
29 |
vectara_customer_id=cfg.customer_id,
|
30 |
vectara_corpus_id=cfg.corpus_id)
|
|
|
|
|
31 |
vectara_tool = QueryEngineTool(
|
32 |
-
query_engine =
|
33 |
-
|
|
|
34 |
metadata = ToolMetadata(name="Vectara",
|
35 |
description="Vectara Query Engine that is able to answer any questions about the Justice Harvard class."),
|
36 |
)
|
@@ -40,7 +43,7 @@ def launch_bot():
|
|
40 |
context = f'''
|
41 |
You are a teacher assistant at Justice Harvard course. You are helping a student with his questions.
|
42 |
The student is {cfg.student_age} years old, so make sure to adapt your response as appropriate to that age.
|
43 |
-
|
44 |
''',
|
45 |
verbose=True
|
46 |
)
|
|
|
7 |
from translate import Translator
|
8 |
|
9 |
|
10 |
+
from llama_index.indices.managed.vectara import VectaraIndex, VectaraQueryEngine
|
11 |
from llama_index.core.agent import ReActAgent
|
12 |
from llama_index.llms.openai import OpenAI
|
13 |
from llama_index.core.tools import QueryEngineTool, ToolMetadata
|
|
|
28 |
vectara = VectaraIndex(vectara_api_key=cfg.api_key,
|
29 |
vectara_customer_id=cfg.customer_id,
|
30 |
vectara_corpus_id=cfg.corpus_id)
|
31 |
+
vectara_retriever = vectara.as_retriever(n_sentences_before=5, n_sentences_after=10,
|
32 |
+
lambda_val=0.005, similarity_top_k=10)
|
33 |
vectara_tool = QueryEngineTool(
|
34 |
+
query_engine = VectaraQueryEngine.from_args(retriever=vectara_retriever, summary_enabled=True,
|
35 |
+
summary_num_results=5, summary_response_lang = languages[cfg.language],
|
36 |
+
summary_prompt_name="vectara-summary-ext-24-05-large"),
|
37 |
metadata = ToolMetadata(name="Vectara",
|
38 |
description="Vectara Query Engine that is able to answer any questions about the Justice Harvard class."),
|
39 |
)
|
|
|
43 |
context = f'''
|
44 |
You are a teacher assistant at Justice Harvard course. You are helping a student with his questions.
|
45 |
The student is {cfg.student_age} years old, so make sure to adapt your response as appropriate to that age.
|
46 |
+
You respond in the {cfg.style} style.
|
47 |
''',
|
48 |
verbose=True
|
49 |
)
|