Merge branch 'main' of github.com:davidkim205/wallstreet-ai
Browse files- intent/intent_parser.py +2 -3
- llm/web_search.py +8 -5
- requirements.txt +3 -1
intent/intent_parser.py
CHANGED
|
@@ -31,8 +31,7 @@ def route_tools(intent):
|
|
| 31 |
return selected
|
| 32 |
|
| 33 |
|
| 34 |
-
|
| 35 |
-
def parse_intent(client, user_query):
|
| 36 |
LLM_MODEL_NAME = os.environ.get('LLM_MODEL_NAME')
|
| 37 |
INTENT_TOOL = {
|
| 38 |
"type": "function",
|
|
@@ -54,7 +53,7 @@ def parse_intent(client, user_query):
|
|
| 54 |
}
|
| 55 |
}
|
| 56 |
}
|
| 57 |
-
response = client.chat.completions.create(
|
| 58 |
model=LLM_MODEL_NAME,
|
| 59 |
messages=[
|
| 60 |
{
|
|
|
|
| 31 |
return selected
|
| 32 |
|
| 33 |
|
| 34 |
+
async def parse_intent(client, user_query):
|
|
|
|
| 35 |
LLM_MODEL_NAME = os.environ.get('LLM_MODEL_NAME')
|
| 36 |
INTENT_TOOL = {
|
| 37 |
"type": "function",
|
|
|
|
| 53 |
}
|
| 54 |
}
|
| 55 |
}
|
| 56 |
+
response = await client.chat.completions.create(
|
| 57 |
model=LLM_MODEL_NAME,
|
| 58 |
messages=[
|
| 59 |
{
|
llm/web_search.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from datetime import datetime
|
| 2 |
import os
|
| 3 |
|
|
|
|
| 4 |
def build_web_search_query(analysis_type, base, target_year, target_quarter, today):
|
| 5 |
if analysis_type == "news_summary":
|
| 6 |
return f"{today} ๊ธฐ์ค {base} ์ต์ ๋ด์ค ๋ฐ ์ฃผ์ ์ด์"
|
|
@@ -14,6 +15,7 @@ def build_web_search_query(analysis_type, base, target_year, target_quarter, tod
|
|
| 14 |
return f"{base} ์ต์ ์ฌ์
ํํฉ, ๊ฒฝ์์ฌ ๋ํฅ, ๋ฆฌ์คํฌ ์์ธ {today}"
|
| 15 |
return f"{base} ์ต์ ํฌ์ ์ ๋ณด ๋ฐ ์์ฅ ๋ํฅ {today}"
|
| 16 |
|
|
|
|
| 17 |
def extract_web_search_blocks(resp):
|
| 18 |
results = []
|
| 19 |
for item in resp.output:
|
|
@@ -22,12 +24,12 @@ def extract_web_search_blocks(resp):
|
|
| 22 |
for block in (getattr(item, "content", []) or []):
|
| 23 |
if getattr(block, "type", None) != "output_text":
|
| 24 |
continue
|
| 25 |
-
text
|
| 26 |
annotations = getattr(block, "annotations", []) or []
|
| 27 |
-
citations
|
| 28 |
{
|
| 29 |
"title": getattr(ann, "title", ""),
|
| 30 |
-
"url":
|
| 31 |
}
|
| 32 |
for ann in annotations
|
| 33 |
if getattr(ann, "type", "") == "url_citation"
|
|
@@ -36,7 +38,8 @@ def extract_web_search_blocks(resp):
|
|
| 36 |
results.append({"text": text.strip(), "citations": citations})
|
| 37 |
return results
|
| 38 |
|
| 39 |
-
|
|
|
|
| 40 |
today = datetime.now().strftime("%Y๋
%m์ %d์ผ")
|
| 41 |
base = f"{company_name}({ticker})" if ticker else company_name
|
| 42 |
query = build_web_search_query(
|
|
@@ -46,7 +49,7 @@ def fetch_web_search(client, ticker, company_name, analysis_type, language="ko",
|
|
| 46 |
results = []
|
| 47 |
LLM_MODEL_NAME = os.environ.get('LLM_MODEL_NAME')
|
| 48 |
try:
|
| 49 |
-
resp = client.responses.create(
|
| 50 |
model=LLM_MODEL_NAME,
|
| 51 |
tools=[
|
| 52 |
{
|
|
|
|
| 1 |
from datetime import datetime
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
|
| 5 |
def build_web_search_query(analysis_type, base, target_year, target_quarter, today):
|
| 6 |
if analysis_type == "news_summary":
|
| 7 |
return f"{today} ๊ธฐ์ค {base} ์ต์ ๋ด์ค ๋ฐ ์ฃผ์ ์ด์"
|
|
|
|
| 15 |
return f"{base} ์ต์ ์ฌ์
ํํฉ, ๊ฒฝ์์ฌ ๋ํฅ, ๋ฆฌ์คํฌ ์์ธ {today}"
|
| 16 |
return f"{base} ์ต์ ํฌ์ ์ ๋ณด ๋ฐ ์์ฅ ๋ํฅ {today}"
|
| 17 |
|
| 18 |
+
|
| 19 |
def extract_web_search_blocks(resp):
|
| 20 |
results = []
|
| 21 |
for item in resp.output:
|
|
|
|
| 24 |
for block in (getattr(item, "content", []) or []):
|
| 25 |
if getattr(block, "type", None) != "output_text":
|
| 26 |
continue
|
| 27 |
+
text = getattr(block, "text", "") or ""
|
| 28 |
annotations = getattr(block, "annotations", []) or []
|
| 29 |
+
citations = [
|
| 30 |
{
|
| 31 |
"title": getattr(ann, "title", ""),
|
| 32 |
+
"url": getattr(ann, "url", ""),
|
| 33 |
}
|
| 34 |
for ann in annotations
|
| 35 |
if getattr(ann, "type", "") == "url_citation"
|
|
|
|
| 38 |
results.append({"text": text.strip(), "citations": citations})
|
| 39 |
return results
|
| 40 |
|
| 41 |
+
|
| 42 |
+
async def fetch_web_search(client, ticker, company_name, analysis_type, language="ko", target_year=None, target_quarter=None):
|
| 43 |
today = datetime.now().strftime("%Y๋
%m์ %d์ผ")
|
| 44 |
base = f"{company_name}({ticker})" if ticker else company_name
|
| 45 |
query = build_web_search_query(
|
|
|
|
| 49 |
results = []
|
| 50 |
LLM_MODEL_NAME = os.environ.get('LLM_MODEL_NAME')
|
| 51 |
try:
|
| 52 |
+
resp = await client.responses.create(
|
| 53 |
model=LLM_MODEL_NAME,
|
| 54 |
tools=[
|
| 55 |
{
|
requirements.txt
CHANGED
|
@@ -8,4 +8,6 @@ tqdm
|
|
| 8 |
jupyter
|
| 9 |
openai
|
| 10 |
fastapi
|
| 11 |
-
uvicorn
|
|
|
|
|
|
|
|
|
| 8 |
jupyter
|
| 9 |
openai
|
| 10 |
fastapi
|
| 11 |
+
uvicorn
|
| 12 |
+
dotenv
|
| 13 |
+
gradio
|