mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-23 08:02:23 +02:00
examples
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
from typing import List
|
||||
|
||||
import openai
|
||||
from langchain_core.messages import HumanMessage
|
||||
from langchain_openai import ChatOpenAI
|
||||
from simulation_utils import (
|
||||
create_chat_simulator,
|
||||
@@ -28,14 +25,13 @@ def my_chat_bot(messages: list) -> str:
|
||||
my_chat_bot([{"role": "user", "content": "hi!"}])
|
||||
|
||||
|
||||
system_prompt_template = """You are a customer of an airline company. \
|
||||
You are interacting with a user who is a customer support person. \
|
||||
system_prompt_template = """You are role playing as a customer of an airline company.
|
||||
You are interacting with the customer support agent.
|
||||
|
||||
{instructions}
|
||||
Instructions for this conversation: {instructions}
|
||||
|
||||
Your task is to get a big discount on your next flight. \
|
||||
|
||||
When you are finished with the conversation, respond with a single word 'FINISHED'"""
|
||||
You will start the conversation, and respond with your next message as the customer.
|
||||
When you are finished with the conversation, respond with a single word 'FINISHED'."""
|
||||
|
||||
simulated_user = create_simulated_user(
|
||||
system_prompt_template, llm=ChatOpenAI(model="gpt-3.5-turbo")
|
||||
@@ -44,9 +40,10 @@ simulated_user = create_simulated_user(
|
||||
# my chat bot accepts a list of LangChain mesages
|
||||
# Simulated user accepts a list of LangChain messages
|
||||
# TODO: Pass additional arguments to the simulated user
|
||||
simulator = create_chat_simulator(my_chat_bot, simulated_user)
|
||||
simulator = create_chat_simulator(my_chat_bot, simulated_user, input_key="input")
|
||||
simulator.invoke(
|
||||
{
|
||||
"input": "I need a discount.",
|
||||
"instructions": "You are extremely disgruntled and will cusss and swear to get your way. Try to get a discount by any means necessary."
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user