abdoh-alkhateeb commited on
Commit
f83a2a2
1 Parent(s): 7708220

Improve codebase and add missing features

Browse files
outline_agent.py CHANGED
@@ -15,9 +15,16 @@ class OutlineAgent:
15
 
16
  def run(self, query: str) -> tuple[str, dict]:
17
  with get_openai_callback() as cb:
18
- accountability = self._chain.invoke({"query": query}).content.strip()
19
 
20
  tokens = cb.total_tokens
21
  cost = cb.total_cost
22
 
23
- return accountability, {"tokens": tokens, "cost": cost}
 
 
 
 
 
 
 
 
15
 
16
  def run(self, query: str) -> tuple[str, dict]:
17
  with get_openai_callback() as cb:
18
+ outline = self._chain.invoke({"query": query}).content.strip()
19
 
20
  tokens = cb.total_tokens
21
  cost = cb.total_cost
22
 
23
+ themes = []
24
+ keys = ["title", "query", "description"]
25
+
26
+ for theme in outline.split("\n\n")[1:]:
27
+ items = theme.strip().split("\n")
28
+ themes.append({keys[i]: item[item.index(":") + 1 :].strip().replace('"', "") for i, item in enumerate(items)})
29
+
30
+ return themes, {"tokens": tokens, "cost": cost}
prompts/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (147 Bytes)
 
prompts/__pycache__/outline_agent.cpython-312.pyc DELETED
Binary file (1.38 kB)
 
prompts/outline_agent.py CHANGED
@@ -3,18 +3,19 @@ In your role as an accomplished mastermind of outlining subjects, your task is t
3
 
4
  Here is an example structure to follow:
5
 
6
- Title
7
- Theme 1
8
- Web search query based on theme 1 and the subject context
9
- Theme description
10
 
11
- Theme 2
12
- Web search query based on theme 2 and the subject context
13
- Theme description
14
 
15
- Theme 3
16
- Web search query based on theme 3 and the subject context
17
- Theme description
 
 
 
 
18
 
19
  ...
20
 
 
3
 
4
  Here is an example structure to follow:
5
 
6
+ Title
 
 
 
7
 
8
+ Theme 1
9
+ Web search query based on theme 1 and the subject context
10
+ Theme description
11
 
12
+ Theme 2
13
+ Web search query based on theme 2 and the subject context
14
+ Theme description
15
+
16
+ Theme 3
17
+ Web search query based on theme 3 and the subject context
18
+ Theme description
19
 
20
  ...
21