Skip to content

Commit

Permalink
fix: prompt engineering
Browse files Browse the repository at this point in the history
  • Loading branch information
seyeong-han committed Nov 24, 2024
1 parent 9f0d4a2 commit 12f0d4a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ async def get_graph_response(text_response, client):
Text to convert:
{text_response}
Expected format:
Expected format example (return only the JSON object, no additional text):
{{
"nodes": [
{{"id": "id1", "name": "Character Name", "val": 10}},
{{"id": id1, "name": "Character Name", "val": 10}}
],
"links": [
{{"source": "id1", "target": "id2"}}
{{"source": id1, "target": "id2"}}
]
}}
id1 and id2 are example variables and you should not generate those exact values.
"""

# Get graph structure from LlamaStack
Expand All @@ -79,6 +80,7 @@ def jsonify_graph_response(response):
"""Extract and parse JSON content from graph response."""
try:
content = response.completion_message.content
print("content: ", content)
# Find indices of first { and last }
start_idx = content.find('{')
end_idx = content.rfind('}')
Expand Down Expand Up @@ -136,6 +138,8 @@ async def process_book(book_title):

graph_response = await get_graph_response(text_response, client)

print("graph_response: ", graph_response)

graph_data = ""
try:
graph_data = jsonify_graph_response(graph_response)
Expand Down

0 comments on commit 12f0d4a

Please sign in to comment.