Files
Anton_wireframe/app/services/__pycache__/openrouter.cpython-312.pyc
T

75 lines
8.5 KiB
Plaintext
Raw Normal View History

Ë
æ³h®ãó€ddlZddlmZmZddlZddlZddlmZddl m
Z
ddl m Z ddl
mZmZddlmZGdd «Zy)
éN)ÚListÚOptional)Ú
InvestorTable)ÚPromptTemplate)Ú
ChatOpenAI)ÚInvestorÚ InvestorList)Úsettingsc ó²eZdZ ddeedeefdZdejdede fdZ
d e e ddfd
Z d e e ddfd Z
dd ejd
edede fdZy)ÚInvestorProcessorNÚ sql_sessionÚvector_db_clientcórd|_t|jdg¬«|_ttj
ddd¬«|_|j jt«|_ ||_
||_ tjd¬ «|_ |jjd
d d i¬
«|_y)Na±You are an expert data extraction assistant. Extract investor information from the provided CSV data and return it as a list of structured records.
Given the following CSV data rows:
{question}
For each row, extract and structure the following fields:
- name: The investor's full name
- aum: Assets under management (as integer, use 0 if not available)
- check_size: Investment check size (as string)
- sector_focus: Sector focus (as string)
- stage_focus: Investment stage focus (as string)
- region: Geographic region (as string)
- investment_thesis: Investment thesis (as string)
- investor_description: Description of the investor (as string)
Important:
- If a field is not available in the data, use appropriate default values (empty string for text fields, 0 for numbers)
- Ensure all text fields are properly escaped and contain no control characters
- Return clean, valid JSON only
Return the data as a structured list of investors.Úquestion)ÚtemplateÚinput_variableszhttps://openrouter.ai/api/v1zopenai/gpt-oss-120b:frer)Úapi_keyÚbase_urlÚmodelÚ temperaturez ./chroma_db)ÚpathÚinvestor_descriptionsÚ descriptionz1Investor descriptions and investment thesis focus)ÚnameÚmetadata)rrÚpromptrr
ÚOPENROUTER_API_KEYÚllmÚwith_structured_outputr Ústructured_llmr
rÚchromadbÚPersistentClientÚget_or_create_collectionÚ
collection)Úselfr
rs úN/home/oluwasanmi/Documents/Work/MKD/anton_wireframe/app/services/openrouter.pyÚ__init__zInvestorProcessor.__init__ð
6ˆŒ
ô,—]‘]°Z°Lô
ˆŒ ôÜ×ô 
ˆŒð#Ÿh™h×=¼lÓÔØÔØ 0ˆÔä (× 9Ñ 9¸}Ô MˆÔØ×ÐðIó
ˆóÚbatchÚ batch_idxÚreturnc
ƒóÆKd}|j«D\}}i}|j«D]s\}}tj|«sŒt |«j dd«j dd«j dd«} dj
d| D««} | ||<Œudj
|j«Dcgc] \}}|d|Œc}}«}
|d |d
zd|
dz
}ŒÕ td |d
zd «|jj|«ƒd
{} | jScc}}w7Œ#t$r } td|d
zd| «gcYd
} ~ Sd
} ~ wwxYw­w)zProcess a single batch of dataÚú
ú ú
ú c3óDK|]}t|«dk\s|dvr|Œy­w)é )r.r0r1N)Úord)Ú.0Úchars r&ú <genexpr>z3InvestorProcessor._process_batch.<locals>.<genexpr>Us+èø€ò*à ܘt›9¨š?¨dÐ6HÑ.Hôñ*ùs z, z: zRow ézProcessing batch z...NzError processing batch ) ÚiterrowsÚitemsÚpdÚnotnaÚstrÚreplaceÚjoinÚprintr ÚainvokeÚ
investor_listÚ Exception)
r%r)r*Ú batch_strÚidxÚrowÚ cleaned_rowÚkeyÚvalueÚ clean_valueÚrow_strÚ
batch_resultsÚes
r&Ú_process_batchz InvestorProcessor._process_batchDszèø€ðˆ ØŸÓ 7‰HˆCàˆKØ!Ÿi™i
3
—8‘8˜E•?ô˜E›
ß  sÓ  sÓ   ð#%§'¡'ñ*à$/ô*ó#
(3K Ò
3ð"—iiØ5@×5FÑ5FÓ5H×I¡z s¨EC5˜˜5˜ˆ
˜4  a¡˜y¨¨7¨)°2Ð 6‰Ið/ 7ð2 Ü Ð% i°!¡m _°CÐ 9Ø"&×"5Ñ"5×"=Ñ"=¸iÓ"H×Hˆ × .ùóJð Iùäò Ü Ð+¨I¸©M¨?¸"¸Q¸ Iûð üs[AE!Á A8E!ÃD- ÃE!Ã,0D5ÄD3ÄD5Ä,E!Ä3D5Ä5 EÄ>EÅEÅE!ÅEÅE!Ú investorsc ƒó8K|jsy|D]j}t|j|j|j|j
|j |j¬«}|jj|«Œl|jj«y­w)zSave investors to SQL databaseN)rÚaumÚ
check_sizeÚ sector_focusÚ stage_focusÚregion)
r
rrrQrRrSrTrUÚaddÚcommit)r%rOÚinvestorÚ db_investors r&Ú _save_to_sqlzInvestorProcessor._save_to_sqlis‡èø€à×ÒØ ð .ˆ—]—Lô
ˆ
× Ñ × Ñ  Õ