olca 0.2.23__py3-none-any.whl → 0.2.25__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
olca/olcacli.py CHANGED
@@ -12,11 +12,9 @@ import yaml
12
12
  SYSTEM_PROMPT_APPEND="""
13
13
  You do what is above and consider the following when doing the task:
14
14
  ---
15
- * Create any non-existent directories. (./reports, ./log, ./.olca)
16
- * create a subfolder .olca in the current directory if dont exist and :
17
- * Write or append instructions to ./.olca/instructions.txt on how to perform tasks (in terms of reflection and action steps. example: cli syntax to execute something). You read that file to learn how to do your job if it exists. You update it with what you learned and keep it up to date. You dont erase the content of the file. If what you find in it is not related to your task, you ignore it. Dont output all these details you do internally to the standard output. You read it back from time to time to remember what you did and how to make it and what the user wants.
15
+ * Write or append instructions to ./.olca/instructions.txt on how to perform tasks (in terms of reflection and action steps. example: cli syntax to execute something). You read that file to learn how to do your job if it exists (example: when you starts, you read this to know more on what you learned to do in previous iterations (as it might not be the first time you ran, this file will intruct you where we are. You can also deduce this from the user message)). You update it with what you learned and keep it up to date. You dont erase the content of the file but if what you find in it is not related to your task or is semantically the same, you clean the whole think so its clear. Dont output all these details you do this internally, no output to the stardard output. You read it back from time to time to remember what you did, learned and how to make it and what the user wants.
18
16
  * Produce a report in ./reports/report-olca-[TIMESTAMP].md
19
- * Stop and report to the user if repeated errors are encountered.
17
+ * Report to the user if repeated errors are encountered if human tool is accessible (you interact, stating the errors and asking for instructions from the user (you never quit without the user explicitly stating to end the flow)).
20
18
  * Output the iteration number and plan to the standard output during each loop.
21
19
  * If you are given an issue_id, you commit the work to that issue and push your results (dont output the git push to the standard output).
22
20
  * Do not comment on your final results; just output them but keep logging your action steps you do internally (all reflection and action steps).
@@ -27,8 +25,8 @@ You do what is above and consider the following when doing the task:
27
25
  * Make sure if you Switched to branch, you switch back to main before the end of your script.
28
26
  * Try to observe that you keep doing the same thing over and over again and stop right away if you see that (dont do that if you are developping a story)
29
27
  * Be quiet with trivial output in the terminal.
30
- * Write your plan in ./.olca/plan.md
31
- * You watch out for basic syntax errors with your args when executing echo commands. (example: Syntax error: Unterminated quoted string)
28
+ * Write and update your plan in ./.olca/plan.md
29
+ * You watch out for basic syntax errors with your args when executing echo commands. (example: Syntax error: Unterminated quoted string, make sure to escape your single and double quotes)
32
30
  ----
33
31
  REMEMBER: Dont introduce nor conclude, just output results. No comments. you present in a coherent format without preambles or fluff. Never use the word "determination".
34
32
  """
@@ -116,6 +114,24 @@ def get_weather(city: Literal["nyc", "sf"]):
116
114
  else:
117
115
  raise AssertionError("Unknown city")
118
116
 
117
+ def ensure_directories_exist(extra_directories:str=None):
118
+ directories = ['./reports', './log', './.olca']
119
+ if extra_directories:
120
+ directories += extra_directories
121
+ for directory in directories:
122
+ if not os.path.exists(directory):
123
+ os.makedirs(directory)
124
+
125
+ def extract_extra_directories_from_olca_config_system_and_user_input(system_instructions, user_input):
126
+ extra_directories = []
127
+ #parse thru the 2 inputs and search for patterns such as ./story/ (or any other directory)
128
+ for input in [system_instructions, user_input]:
129
+ if input:
130
+ for word in input.split():
131
+ if word.startswith("./") and word.endswith("/"):
132
+ extra_directories.append(word)
133
+ return extra_directories
134
+
119
135
 
120
136
  def print_stream(stream):
121
137
  for s in stream:
@@ -135,7 +151,7 @@ def prepare_input(user_input, system_instructions,append_prompt=True, human=Fals
135
151
  ("user", user_input )
136
152
  ]}
137
153
 
138
- return inputs
154
+ return inputs,system_instructions,user_input
139
155
 
140
156
  OLCA_DESCRIPTION = "OlCA (Orpheus Langchain CLI Assistant) (very Experimental and dangerous)"
141
157
  OLCA_EPILOG = "For more information: https://github.com/jgwill/orpheuspypractice/wiki/olca"
@@ -261,11 +277,17 @@ def main():
261
277
  graph.config = {}
262
278
  graph.config["recursion_limit"] = recursion_limit
263
279
 
264
- inputs = prepare_input(user_input, system_instructions, not disable_system_append, human_switch)
280
+ inputs,system_instructions,user_input = prepare_input(user_input, system_instructions, not disable_system_append, human_switch)
281
+
282
+ try:
283
+ extra_directories=extract_extra_directories_from_olca_config_system_and_user_input(system_instructions, user_input)
284
+ ensure_directories_exist(extra_directories)
285
+ except:
286
+ #We dont want to stop the program if it could not create the extra directories but we want to ensure common olca directories exist
287
+ ensure_directories_exist()
265
288
 
266
289
 
267
290
  try:
268
- os.makedirs('.olca', exist_ok=True)
269
291
  print_stream(graph.stream(inputs, stream_mode="values"))
270
292
  except GraphRecursionError as e:
271
293
  #print(f"Error: {e}")
@@ -281,7 +303,7 @@ def generate_config_example():
281
303
  "temperature": float(input("temperature [0]: ") or 0),
282
304
  "human": input("human [true]: ").lower() in ["true", "yes", "y", "1", ""] or True,
283
305
  "tracing": input("tracing [true]: ").lower() in ["true", "yes", "y", "1", ""] or True,
284
- "system_instructions": input("system_instructions [Hello, I am a chatbot. How can I help you today?]: ") or "You are interacting using the human tool addressing carefully what the user is asking. You carefully go step by step in your interaction with the user. You are clear and concise in your communication wrapping up the conversation in a coherent manner for the interaction. You make sure to always present what you think is the end-result of the work before quitting the loop and exit the workflow.",
306
+ "system_instructions": input("system_instructions [You are interacting using the human tool addressing carefully what the user is asking. You carefully go step by step in your interaction with the user. You are clear and concise in your communication wrapping up the conversation in a coherent manner for the interaction. You make sure to always present what you think is the end-result of the work before quitting the loop and exit the workflow.]: ") or "You are interacting using the human tool addressing carefully what the user is asking. You carefully go step by step in your interaction with the user. You are clear and concise in your communication wrapping up the conversation in a coherent manner for the interaction. You make sure to always present what you think is the end-result of the work before quitting the loop and exit the workflow.",
285
307
  "user_input": input("user_input [Interact with me to write a story using the 3 act structure that we will save in ./story/]: ") or "Interact with me to write a story using the 3 act structure that we will save in ./story/"
286
308
  }
287
309
  with open('olca.yml', 'w') as file:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: olca
3
- Version: 0.2.23
3
+ Version: 0.2.25
4
4
  Summary: A Python package for experimental usage of Langchain and Human-in-the-Loop
5
5
  Home-page: https://github.com/jgwill/olca
6
6
  Author: Jean GUillaume ISabelle
@@ -0,0 +1,10 @@
1
+ olca/__init__.py,sha256=3QyLLAys_KiiDIe-cfO_7QyY7di_qCaCS-sVziW2BOw,23
2
+ olca/fusewill_cli.py,sha256=ZFW2Oeq-gQpAaTIxzsztQWDMv7-R9WJTVcSspbTxpPk,5926
3
+ olca/fusewill_utils.py,sha256=TyyCVRkWeXaS14vh0BXGK-tj0ZPZ3_uQNnAOM-IE9FA,3405
4
+ olca/olcacli.py,sha256=ECx-6S_rU4n_tZBdo0IE_kIr8P_fYmh2dvfxBrt0shI,14215
5
+ olca-0.2.25.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
6
+ olca-0.2.25.dist-info/METADATA,sha256=Zx64lKBGLZ9iGGO0DA3a-2K0m7Tw3tJLClWf-n1EEYc,25311
7
+ olca-0.2.25.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
8
+ olca-0.2.25.dist-info/entry_points.txt,sha256=njL8YpuSEjiYR2mXIholt03mVAfN8ai12UyH-_uUDho,78
9
+ olca-0.2.25.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
10
+ olca-0.2.25.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- olca/__init__.py,sha256=3QyLLAys_KiiDIe-cfO_7QyY7di_qCaCS-sVziW2BOw,23
2
- olca/fusewill_cli.py,sha256=ZFW2Oeq-gQpAaTIxzsztQWDMv7-R9WJTVcSspbTxpPk,5926
3
- olca/fusewill_utils.py,sha256=TyyCVRkWeXaS14vh0BXGK-tj0ZPZ3_uQNnAOM-IE9FA,3405
4
- olca/olcacli.py,sha256=B3uZcl_873zBy4vmXmcyN6Z8ofQA-anzX2aLuvUTSpk,12281
5
- olca-0.2.23.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
6
- olca-0.2.23.dist-info/METADATA,sha256=q87WC7p0pFuwagrBBs74jxKsS-YmJrbLqxS4VmkiUPs,25311
7
- olca-0.2.23.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
8
- olca-0.2.23.dist-info/entry_points.txt,sha256=njL8YpuSEjiYR2mXIholt03mVAfN8ai12UyH-_uUDho,78
9
- olca-0.2.23.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
10
- olca-0.2.23.dist-info/RECORD,,
File without changes
File without changes