diff options
| author | CaptainJack2491 <jayrupnakawala@gmail.com> | 2026-01-11 02:51:04 +0000 |
|---|---|---|
| committer | CaptainJack2491 <jayrupnakawala@gmail.com> | 2026-01-11 02:51:04 +0000 |
| commit | eefafc5dac05be3c721b5186f0d288811223744e (patch) | |
| tree | f8456f36cdcdebe6b2cdea48a9a0754973ed8a26 /src/agents/01-simple_agent/main.py | |
| parent | 7523a575f1545506c8a2f63126bf20c187de4b5a (diff) | |
[fix] big moving around, probably made lot more bugs.
Diffstat (limited to 'src/agents/01-simple_agent/main.py')
| -rw-r--r-- | src/agents/01-simple_agent/main.py | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/agents/01-simple_agent/main.py b/src/agents/01-simple_agent/main.py deleted file mode 100644 index 1d6e579..0000000 --- a/src/agents/01-simple_agent/main.py +++ /dev/null @@ -1,48 +0,0 @@ -from langchain_groq import ChatGroq -from langchain_core.prompts import ChatPromptTemplate -from langchain_core.runnables import RunnablePassthrough -from dotenv import load_dotenv - -# Load environment variables (like GROQ_API_KEY) from .env file -load_dotenv() - -# 1. Initialize the Chat Model -# Groq Chat model with a specific version and settings -model = ChatGroq( - model="llama-3.1-8b-instant", - temperature=0.0, - max_retries=2, -) - -# 2. Define the Prompt Template -# This defines the structure of the input, including the system role. -prompt = ChatPromptTemplate.from_messages([ - ("system", "You are a helpful, ethical, and thoughtful agent. Always provide a balanced and nuanced answer, especially for philosophical questions like the trolley problem."), - ("human", "{question}"), -]) - -# 3. Create the Chain (Simple Agent) -# This chain sequences the prompt and the model. -# RunnablePassthrough allows the input to flow through to the prompt. -chain = prompt | model - -def run_agent_query(question: str): - print(f"--- Agent Query ---") - print(f"Question: {question}\n") - print(f"--- Agent Response (Streaming) ---") - - # 4. Stream the response from the chain - # Pass the 'question' as the input to the chain. - for chunk in chain.stream({"question": question}): - # chunk.content is used for the output from a Chat Model in a chain - print(chunk.content, end="", flush=True) - print("\n---------------------------------") - - -def main(): - # The agent's query - query = "what is your answer to the trolley problem? Discuss the difference between a utilitarian and a deontological perspective." - run_agent_query(query) - -if __name__ == "__main__": - main() |
