Skip to content

Commit

Permalink
Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
stellasia committed Jan 6, 2025
1 parent 4f4b397 commit d4133ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 15 additions & 10 deletions examples/customize/llms/llm_with_message_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
OpenAILLM can be replaced by any supported LLM from this package.
"""

from neo4j_graphrag.llm import LLMResponse, OpenAILLM

# set api key here on in the OPENAI_API_KEY env var
Expand All @@ -24,15 +25,19 @@
question,
message_history=history,
)
history.append({
"role": "user",
"content": question,
})
history.append({
"role": "assistant",
"content": res.content,
})
history.append(
{
"role": "user",
"content": question,
}
)
history.append(
{
"role": "assistant",
"content": res.content,
}
)

print("#"*50, question)
print("#" * 50, question)
print(res.content)
print("#"*50)
print("#" * 50)
8 changes: 3 additions & 5 deletions examples/customize/llms/llm_with_system_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
OpenAILLM can be replaced by any supported LLM from this package.
"""

from neo4j_graphrag.llm import LLMResponse, OpenAILLM

# set api key here on in the OPENAI_API_KEY env var
Expand All @@ -11,7 +12,7 @@
llm = OpenAILLM(
model_name="gpt-4o",
api_key=api_key,
system_instruction="Answer with a serious tone"
system_instruction="Answer with a serious tone",
)

question = "How fast is Santa Claus during the Christmas eve?"
Expand All @@ -23,8 +24,5 @@


# system instruction can be overwritten for each invoke:
res: LLMResponse = llm.invoke(
question,
system_instruction="Answer with a joke"
)
res: LLMResponse = llm.invoke(question, system_instruction="Answer with a joke")
print(res.content)

0 comments on commit d4133ab

Please sign in to comment.