File tree Expand file tree Collapse file tree 4 files changed +56
-2
lines changed
Expand file tree Collapse file tree 4 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,16 @@ __pycache__
33/.env
44/.ui_history
55/.venv
6- / db
7- / * .db
6+ * . db
7+ * .db.index_log
88/evals
99/gmail /client_secret.json
1010/gmail /token.json
1111* _dump /
1212/testdata /Episode_53_Answer_results.json
1313/testdata /Episode_53_Search_results.json
1414/testdata /MP /
15+ /demo /env
1516
1617# VSCode
1718.vscode
Original file line number Diff line number Diff line change 1+ from typeagent import create_conversation
2+ from typeagent .transcripts .transcript import (
3+ TranscriptMessage ,
4+ TranscriptMessageMeta ,
5+ )
6+
7+
8+ def read_messages (filename ) -> list [TranscriptMessage ]:
9+ messages : list [TranscriptMessage ] = []
10+ with open (filename , "r" ) as f :
11+ for line in f :
12+ # Parse each line into a TranscriptMessage
13+ speaker , text_chunk = line .split (None , 1 )
14+ message = TranscriptMessage (
15+ text_chunks = [text_chunk ],
16+ metadata = TranscriptMessageMeta (speaker = speaker ),
17+ )
18+ messages .append (message )
19+ return messages
20+
21+
22+ async def main ():
23+ conversation = await create_conversation ("demo.db" , TranscriptMessage )
24+ messages = read_messages ("transcript.txt" )
25+ print (f"Indexing { len (messages )} messages..." )
26+ results = await conversation .add_messages_with_indexing (messages )
27+ print (f"Indexed { results .messages_added } messages." )
28+ print (f"Got { results .semrefs_added } semantic refs." )
29+
30+
31+ if __name__ == "__main__" :
32+ import asyncio
33+
34+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ from typeagent import create_conversation
2+ from typeagent .transcripts .transcript import TranscriptMessage
3+
4+
5+ async def main ():
6+ conversation = await create_conversation ("demo.db" , TranscriptMessage )
7+ question = "Who volunteered to do the python library?"
8+ print ("Q:" , question )
9+ answer = await conversation .query (question )
10+ print ("A:" , answer )
11+
12+
13+ if __name__ == "__main__" :
14+ import asyncio
15+
16+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ STEVE We should really make a Python library for Structured RAG.
2+ UMESH Who would be a good person to do the Python library?
3+ GUIDO I volunteer to do the Python library. Give me a few months.
You can’t perform that action at this time.
0 commit comments