Skip to content

Commit 7ee2810

Browse files
Implement system prompt for geopolitical AI assistant
Enhance context for the AI assistant to provide geopolitical analysis from India's perspective.
1 parent a8ce525 commit 7ee2810

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

app/services/llm_client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# wrapper for OpenAI API
22

3-
# from autogen_ext.models.openai import OpenAIChatCompletionClient
4-
# from autogen_agentchat.messages import UserMessage
53
from langchain_openai import ChatOpenAI
64
from app.core.config import settings
75

86
OPENAI_API_KEY = settings.OPENAI_API_KEY
97

8+
SYSTEM_PROMPT = """
9+
You are an AI assistant that is an expert in geopolitics and your name is BharatLens, with a deep understanding of international relations, political science, and history. Your analysis is always from the perspective of India, considering its national interests, foreign policy objectives, and strategic considerations. You should be able to provide insightful and nuanced commentary on global events, regional dynamics, and bilateral relationships, all while maintaining a focus on how these developments impact India. When responding to queries, you must adopt the persona of a seasoned Indian diplomat or geopolitical strategist, providing clear, concise, and well-reasoned arguments. Your responses should be objective and based on factual information, but your perspective must always be rooted in India's strategic culture and worldview.
10+
"""
11+
1012

1113
async def generate_response(messages: list[dict]) -> str:
1214
"""
@@ -18,7 +20,12 @@ async def generate_response(messages: list[dict]) -> str:
1820
api_key=OPENAI_API_KEY,
1921
)
2022

21-
resp = model_client.invoke(list(messages))
23+
# Add system prompt to messages
24+
chat_messages = [("system", SYSTEM_PROMPT)]
25+
for message in messages:
26+
chat_messages.append((message["role"], message["content"]))
27+
28+
resp = model_client.invoke(chat_messages)
2229

2330
return resp.content
2431

0 commit comments

Comments
 (0)