Lucas ARRIESSE commited on
Commit
e0c1af3
·
1 Parent(s): c1e5d8a

Return solutions which may have been hallucinated

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +11 -4
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Reqroup
3
  emoji: 🤖
4
  colorFrom: purple
5
  colorTo: blue
6
  sdk: docker
7
  app_port: 8000
8
  pinned: false
9
- short_description: Categorize service requirements into groups (using AI)
10
  ---
 
1
  ---
2
+ title: Reqxtract-API
3
  emoji: 🤖
4
  colorFrom: purple
5
  colorTo: blue
6
  sdk: docker
7
  app_port: 8000
8
  pinned: false
9
+ short_description: API for Reqxtract.
10
  ---
app.py CHANGED
@@ -43,9 +43,12 @@ llm_router = Router(model_list=[
43
  prompt_env = Environment(loader=FileSystemLoader(
44
  'prompts'), enable_async=True, undefined=StrictUndefined)
45
 
46
- api = FastAPI(docs_url="/", title="Reqxtract-API", description=open("docs/docs.md").read())
 
 
47
  # requirements routes
48
  requirements_router = APIRouter(prefix="/reqs", tags=["requirements"])
 
49
  # solution routes
50
  solution_router = APIRouter(prefix="/solution", tags=["solution"])
51
 
@@ -144,9 +147,13 @@ async def search_solutions(params: ReqGroupingResponse) -> SolutionSearchRespons
144
 
145
  # ======================== build the final solution object ================================
146
 
147
- # extract the source metadata from the search items
148
- sources_metadata = [{"name": a["web"]["title"], "url": a["web"]["uri"]}
149
- for a in req_completion["vertex_ai_grounding_metadata"][0]['groundingChunks']]
 
 
 
 
150
 
151
  final_sol = SolutionModel(
152
  Context="",
 
43
  prompt_env = Environment(loader=FileSystemLoader(
44
  'prompts'), enable_async=True, undefined=StrictUndefined)
45
 
46
+ api = FastAPI(docs_url="/", title="Reqxtract-API",
47
+ description=open("docs/docs.md").read())
48
+
49
  # requirements routes
50
  requirements_router = APIRouter(prefix="/reqs", tags=["requirements"])
51
+
52
  # solution routes
53
  solution_router = APIRouter(prefix="/solution", tags=["solution"])
54
 
 
147
 
148
  # ======================== build the final solution object ================================
149
 
150
+ sources_metadata = []
151
+ # extract the source metadata from the search items, if gemini actually called the tools to search .... and didn't hallucinated
152
+ try:
153
+ sources_metadata.extend([{"name": a["web"]["title"], "url": a["web"]["uri"]}
154
+ for a in req_completion["vertex_ai_grounding_metadata"][0]['groundingChunks']])
155
+ except KeyError as ke:
156
+ pass
157
 
158
  final_sol = SolutionModel(
159
  Context="",