Skip to content

Commit c5b279c

Browse files
authored
Fix fewshot examples (neo4j#54)
1 parent 4201791 commit c5b279c

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

api/src/fewshot_examples.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import os
2-
3-
openai_api_key = os.environ.get("OPENAI_API_KEY", "")
4-
5-
fewshot_examples = {}
6-
7-
fewshot_examples[
8-
"companies"
9-
] = f"""
1+
def get_fewshot_examples(openai_api_key):
2+
return f"""
103
#How is Emil Eifrem connected to Michael Hunger?
114
MATCH (p1:Person {{name:"Emil Eifrem"}}), (p2:Person {{name:"Michael Hunger"}})
125
MATCH p=shortestPath((p1)-[*]-(p2))

api/src/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from fastapi import FastAPI, HTTPException, WebSocket, WebSocketDisconnect
1616
from fastapi.middleware.cors import CORSMiddleware
1717
from fastapi.responses import JSONResponse
18-
from fewshot_examples import fewshot_examples
18+
from fewshot_examples import get_fewshot_examples
1919
from llm.openai import OpenAIChat
2020
from pydantic import BaseModel
2121

@@ -141,7 +141,7 @@ async def onToken(token):
141141
text2cypher = Text2Cypher(
142142
database=neo4j_connection,
143143
llm=default_llm,
144-
cypher_examples=fewshot_examples["companies"],
144+
cypher_examples=get_fewshot_examples(api_key),
145145
)
146146

147147
if "type" not in data:

0 commit comments

Comments
 (0)