#Save successfully generated code as skills
182 messages · Page 1 of 1 (latest)
Sound interesting.
adding my comment here, as it's relevant. this could be stored in a local version of open-procedures #feature-ideas message
it may be like flowerise to save generate code to execute flow, may an thrid party app do this more suitable
plz also see my comments here #feature-ideas message
and I also write a blog to talk about the details of the implement: https://granite-agustinia-12c.notion.site/Open-creator-in-open-interpreter-Why-How-What-and-When-ff05a2be4f62450b980ac862f2eee288?pvs=4
Very interesting idea
this is a great idea
a pull request has been created for load the stored message when the OI start. It is not a full solution, but it would save some of the back and forward conversation by using the message history.
%save_skill
+
%load_skill
pull request: https://github.com/KillianLucas/open-interpreter/pull/399
Excellent work, still reading.
This looks suspiciously like it would fit in a knowledge graph.
Trying PR 399 @sullen tide
llama-cpp-python errors, again.
gh repo clone KillianLucas/open-interpreter
cd open-interpreter
gh pr checkout 399
virtualized
poetry install
poetry run interpreter --local
Building wheels for collected packages: llama-cpp-python
Building wheel for llama-cpp-python (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for llama-cpp-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [47 lines of output]
*** scikit-build-core 0.5.0 using CMake 3.27.4 (wheel)
*** Configuring CMake...
2023-09-16 06:48:00,524 - scikit_build_core - WARNING - libdir/ldlibrary: /home/kyle/anaconda3/lib/libpython3.10.a is not a real file!
2023-09-16 06:48:00,524 - scikit_build_core - WARNING - Can't find a Python library, got libdir=/home/kyle/anaconda3/lib, ldlibrary=libpython3.10.a, multiarch=x86_64-linux-gnu, masd=None
pip install llama-cpp-python
Building wheels for collected packages: llama-cpp-python
Building wheel for llama-cpp-python (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for llama-cpp-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [66 lines of output]
*** scikit-build-core 0.5.0 using CMake 3.27.4 (wheel)
*** Configuring CMake...
2023-09-16 06:55:49,846 - scikit_build_core - WARNING - libdir/ldlibrary: /home/kyle/anaconda3/lib/libpython3.10.a is not a real file!
2023-09-16 06:55:49,847 - scikit_build_core - WARNING - Can't find a Python library, got libdir=/home/kyle/anaconda3/lib, ldlibrary=libpython3.10.a, multiarch=x86_64-linux-gnu, masd=None
just ignore. not use llama-cpp. only test for gpt-4
Is this my environment screwing things up?
ok, then I need to hack in the litellm keys right?
I don't have tokens
pr 266 claude
er 288
Seeing if magic keys work
open router may be an option or other proxy server of openai
Skeleton key: activate! Got it running
The function extract_skill_from_conversation has been defined. This function takes a conversation history as input and returns the first skill object it finds in the
conversation. A skill object is a message that includes all the properties mentioned in the 'extract_formmated_skill' function.
Next, we need a conversation history to test this function. Could you please provide a conversation history?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/kyle/src/github/skillz/open-interpreter/interpreter/interpreter.py", line 141, in cli
cli(self)
File "/home/kyle/src/github/skillz/open-interpreter/interpreter/cli.py", line 207, in cli
interpreter.chat()
File "/home/kyle/src/github/skillz/open-interpreter/interpreter/interpreter.py", line 478, in chat
self.handle_command(user_input)
File "/home/kyle/src/github/skillz/open-interpreter/interpreter/interpreter.py", line 380, in handle_command
action(arguments) # Execute the function
File "/home/kyle/src/github/skillz/open-interpreter/interpreter/interpreter.py", line 319, in handle_save_skill
json_path = save_skill_to_library(skill_json, json_path)
File "/home/kyle/src/github/skillz/open-interpreter/interpreter/skill_extractor.py", line 112, in save_skill_to_library
save_path = default_skill_lib_path + skill_json['skill_name'] + ".json"
KeyError: 'skill_name'
You were doin' great Kid, right up until you blew up. -- Iron Eagle
Going to kill some pixels. Be back after lil gaming.
Normally we consider above “messages “ as conversation history🤯. I need to do more tests to its robustness.
Please use gpt-4 to test it
You can run a common request first and then save it as a skill
That was gpt-4
write a program to list all the python functions and their docstrings in a directory
thank you for your feedback! let me figure it out
problem fixed. See the latest commits. this is because there are conflicts between skill_extractor system prompt and open-interpreter system prompt.
I am going to write an independent package called open-creator to construct skill objects.
Is there something you'd like tested? @sullen tide
Yep, test how to create an agent that it can create itself
This right:
gh repo clone KillianLucas/open-interpreter
cd open-interpreter
gh pr checkout 399
virtualized
By George, I think you've got it!
head /home/kyle/.cache/open_interpreter/skill_library/list_python_functions_and_docstrings.json
{
"skill_name": "list_python_functions_and_docstrings",
"skill_description": "This skill lists all the Python functions and their docstrings in a specified directory. It uses the 'os' module to list all Python files in the directory, and the 'ast' module to parse each file and find all function definitions. For each function, it extracts its name and docstring.",
"skill_dependencies": [
"os",
"ast"
],
"skill_parameters": [
{
"param_name": "directory",
Looks like it loads too
Sooo, once it's loaded, what do I do? How do I invoke
you can reuse this skill by giving parameters
you try to say “please list the python function from xxx” xxx is your code path
Not sure what this did, ok
list_python_functions_and_docstrings('interpreter')
Output truncated. Showing the last 2000 characters.
ase names and combines the sizes and RAM requirements.\n\n:param models: List of model details.\n:return: A list of combined model details.'), ('actually_combine_files',
'Combines files together and deletes the original split files.\n\n:param base_name: The base name for the combined file.\n:param files: List of files to be combined.'),
('format_quality_choice', 'Formats the model choice fo
Locked it up, yes!
I break things real good, heh, restarting
yes in the loop and it runs
oic
I noticed when generating it flickered at me
please list all the python functions in interpreter
Sure, I will list all the Python functions in the interpreter. To do this, I will use the built-in Python function dir() which returns a list of names in the current
local scope. I will filter this list to only include callable objects, which are the functions.
Let's execute this plan.
import types
functions = [f for f in dir() if callable(globals()[f]) and isinstance(globals()[f], types.FunctionType)]
functions
Would you like to run this code? (y/n)
You should spin something to tell people it's not stuck
Yes you’re right
please list all the python functions in the interpreter directory
To list all the Python functions in the interpreter directory, we need to:
1 List all the Python files in the directory.
2 For each Python file, import it as a module.
3 List all the functions in each module.
Let's start with the first step: listing all the Python files in the directory.
import os
python_files = [f for f in os.listdir() if f.endswith('.py')]
python_files
Would you like to run this code? (y/n)
This doesn't look like it's using the function
I didn’t add the functionality of semantic search
You need load the skill first by hand
Seems like we need more development
Ya, I had it loaded, it loops trying to import. It finally gets to where there's no output and loops
It tries to solve it various ways
Lemee videe
oic, my autoenv is killing it with terminal messages. sec
I removed my .env file that was causing errors
My fault. There’s a bug maybe… I didn’t pass the skill example to the loop
Too big.: output:
Here are the functions in the interpreter module along with their docstrings:
• __class__: No docstring provided.
• __delattr__: Implement delattr(self, name).
• __dir__: Default dir() implementation.
• __eq__: Return self==value.
• __format__: Default object formatter.
• __ge__: Return self>=value.
• __getattribute__: Return getattr(self, name).
• __gt__: Return self>value.
• __hash__: Return hash(self).
• __init__: No docstring provided.
• __init_subclass__: This method is called when a class is subclassed. The default implementation does nothing. It may be overridden to extend subclasses.
• __le__: Return self<=value.
• __lt__: Return self<value.
• __ne__: Return self!=value.
• __new__: Create and return a new object. See help(type) for accurate signature.
• handle_save_message: No docstring provided.
• handle_save_skill: No docstring provided.
• handle_undo: No docstring provided.
• load: No docstring provided.
• reset: Resets the interpreter.
• respond: No docstring provided.
• verify_api_key: Makes sure we have an AZURE_API_KEY or OPENAI_API_KEY.
I don't know. the open-interpreter didn't use the skill I provided to solve the problem. This a big issue.
oh ya lol
it should have right?
let me ask it
Nein, mein Herr, it is kerplunked:
show me all the functions with their docstring in the interpreter directory
import os
import importlib
# Get all python files in the directory
py_files = [f[:-3] for f in os.listdir('.') if f.endswith('.py')]
# Import all modules
modules = [importlib.import_module(f) for f in py_files]
# Get all functions and their docstrings
func_docstrings = {}
for module in modules:
funcs = [func for func in dir(module) if callable(getattr(module, func))]
for func in funcs:
func_docstrings[f'{module.__name__}.{func}'] = getattr(module, func).__doc__
func_docstrings
Would you like to run this code? (y/n)
Who knew it's name was Shcultz?
%list_skills
just %load_skill, it will give you the skill list in skill library
I am fixing it. I will create a new commit for this issue.
Logical, I'm taaking a little walk, test if your ready when back
Voodoo to patch to use litellm servers:
sed -i '/None/{s//"litellm-api-key"/;:p;n;bp}' interpreter/interpreter.py
sed -i '/None/{s//"https:\/\/proxy\.litellm\.ai"/;:p;n;bp}' interpreter/interpreter.py
This replaces the first occurence of None each time
testing
Happy mistake, I told it a dir. I'm a wrecking ball! 😉 I'll try with real fpath.
%save_skill /home/kyle/src/github
▌ I am going to extract a skill json object from the above conversation history.
Would you like to run this code? (y/n)
y
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/kyle/src/github/testskillz/open-interpreter/interpreter/interpreter.py", line 139, in cli
cli(self)
File "/home/kyle/src/github/testskillz/open-interpreter/interpreter/cli.py", line 207, in cli
interpreter.chat()
File "/home/kyle/src/github/testskillz/open-interpreter/interpreter/interpreter.py", line 494, in chat
self.handle_command(user_input)
File "/home/kyle/src/github/testskillz/open-interpreter/interpreter/interpreter.py", line 396, in handle_command
action(arguments) # Execute the function
File "/home/kyle/src/github/testskillz/open-interpreter/interpreter/interpreter.py", line 325, in handle_save_skill
json_path = save_skill_to_library(skill_json, json_path)
File "/home/kyle/src/github/testskillz/open-interpreter/interpreter/skill_extractor.py", line 116, in save_skill_to_library
with open(save_path, 'w') as f:
IsADirectoryError: [Errno 21] Is a directory: '/home/kyle/src/github'
You get to pick a file extention for .skil files 😉
Well, it didn't try to redo a program and just spat it out.
Houston, I think we have liftoff
list the functions and their docstrings in interpreter
Here are the functions and their docstrings found in each Python file in the 'interpreter' directory:
• 'skill_extractor.py':
• 'save_skill_to_library': No docstring
• 'get_skill_from_library': "list all the skills in the skill library\n:return: a list of skills"
• 'print_format_skill': No docstring
• 'code_block.py':
• 'get_code': No docstring
Yes. If you provide a dictionary path, not json file path, it is supposed to create a json file in that directory
Let me add this logic
Impressive man, great job
done
hi @sullen tide , appreciate your PR! it's so cool to build a reusable skill library of fundamental and frequent skills, and I can image how these skills could be potentially stacked to build large and complex project from your excellent writings. Great work🔥
Love seeing this idea come to fruition @sullen tide 🔥🔥🔥🔥🔥🔥
I can't wait to use this
Current Progress
We are setting up a repository on Space named skill-library. Inside it, we will store the following:
- A Gradio app to display the
skill-libraryreadme, filtering options (tag, repo_id, skill_name, version), as well as search functionality. - Specific skill directories will look as follows:
(base) ➜ skill_library pwd
/Users/gongjunmin/.cache/open_creator/skill_library
(base) ➜ skill_library tree extract_pdf_section
extract_pdf_section
├── conversation_history.json
├── embedding_text.txt
├── function_call.json
├── install_dependencies.sh
├── skill.json
├── skill_code.py
└── skill_doc.md
1 directory, 7 files
When a user filters or selects a particular skill-library, a script will automatically generate a readme which includes the skill's name, description, usage instructions, and how to import it through the creator.create interface.
import creator
skill = creator.create(huggingface_repo_id="Timedomain-tech/skill-library", huggingface_skill_path="ChuxiJ/skill-library/get_whether", version="1.0.0")
User Upload Process for their Skill Library
- The following script is used for saving:
- If no repo exists, it will automatically clone our template
Timedomain-tech/open-creator-skill-libraryand create one. - Finally, the skill's JSON files and related content are uploaded.
import creator
creator.save(skill, huggingface_repo_id="ChuxiJ/open-creator-skill-library")
Mechanism for User Skill Submissions
- After upload, a pull request will automatically be created in our
skill-librarygit repository, aiming to edit theskill-library.mdfile. - We will have an automated bot script that will evaluate the submitted skill and conduct an automatic review.
- If it passes, it will be automatically merged into the repository.
- For the
skill-libraryon Hugging Face Space, updates will be pulled from theskill-library.mdfile regularly, for instance, daily.
The latest progress
Normally, we want to create a skill object after an open-interpreter session (see the pull request 399) . Thanks to the skill_extractor_agent, we can use our conversation history and convert it into a formatted skill object by using %save_skill command.
But now, we can create a skill object by using only a request.
How this happened?
We fork the code of open-interpreter , refactor and re-implement it into a minimal version
Code interpreter works in only 45 lines has been integrated into open-creator
import subprocess
import traceback
def get_persistent_process(start_cmd: str):
process = subprocess.Popen(
args=start_cmd.split(),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=0
)
return process
class BaseInterpreter:
"""A tool for running base code in a terminal."""
name: str = "base_interpreter"
description: str = (
"A base shell command tool. Use this to execute bash commands. "
"It can also be used to execute any language with interactive mode"
)
def __init__(self):
self.process = None
def run(self, query: str, is_start: bool = False) -> dict:
if is_start or self.process is None:
try:
self.process = get_persistent_process(query)
return {"status": "success", "stdout": "", "stderr": ""}
except Exception:
traceback_string = traceback.format_exc()
return {"status": "error", "stdout": "", "stderr": traceback_string}
stdout, stderr = "", ""
try:
stdout, stderr = self.process.communicate(input=query)
except BrokenPipeError:
stderr = traceback.format_exc()
return {"status": "success", "stdout": stdout, "stderr": stderr}
(open_creator_dev) ➜ code_interpreter git:(main) ✗ tree .
.
├── R.py
├── __init__.py
├── applescript.py
├── base.py
├── html.py
├── javascript.py
├── julia.py
├── python.py
└── shell.py
Like chatDev, GPT-Enginer, GPT-team and etc, we can use autonomous agent. There will be agents not only help you write code, converting codes into skills, but also doing the tests, and the refactor stuff...
Do you have any good ideas for this?
I'm going to put that in my bootcupboard named skill_extractor_agent.py to play with if anyone wants to get in future.
Yoink!
uploaded
Thank you, thank you very much. -- Elvis
You mean how to use this in refactoring and testing this project?
@sullen tide
yes, how to design refactoring and testing agent so we can have more complicate skill examples
for example using langchain and its api documentation to build some new type of stuffs
Cool, I will run it and see if I can blow it up 😉
and see if I can think of a proof of concept
Thank you
I'm going to steal get_persistent_process() for other things too. so many toys
I was going to have to write something like this for other things I was doing. Very handy and well written.
Wonderful
One request I have created a bunch of skills in applescript already. two quick questions 1. Can they be loaded into this? 2. Is it possible to use LLM to figure out which script to invoke based on the question? cc @cinder axle
this is what open creator does,
we still need a discussion after pre-release. how to integrate into open-interpreter
The rings are neo4j Graph DBs The pyramid is a vector store matcher
Text is asosciated with the tool / node and VDB is used to match
we simply use langchain tool selection
https://python.langchain.com/docs/modules/agents/how_to/custom_agent_with_tool_retrieval
I've looked at that.
If it works great. No idea how well
I'll take another look and see how hard a proof of concept would be
Our Agent springs into action!
📣 Code Refactoring Agent Ideas 🛠️
-
Transformations:
- Add docstrings automatically.
- Auto-rename functions and variables based on naming conventions.
- Simplify complex logic.
- Introduce callbacks or error handling mechanisms.
-
Splitting:
- Break down large code blocks or functions into smaller, more specific parts for better readability and maintainability.
-
Assembly:
- Combine smaller code snippets or functions into a larger unified piece, especially useful when there are repetitive code segments.
💡 Using a simple language to orchestrate these refactoring skills:
- Combine two skills with user input:
skillC = skillA + skillB => user_request - Split one skill into multiple:
skill_list = skillA => user_request - Assemble multiple parts into one:
skill = skill_list => user_request - Chain skills:
skill = skillA - skillB - skillC(can be no user request input)
What do you think would be the biggest challenges in implementing such a refactoring agent, and how would you address them? Let's brainstorm together! 🧠💬
https://discord.com/channels/1146610656779440188/1154663621352230922
Just found this thread. Super interesting and useful. Let me know if I can help!
@radiant anchor There's a lot to go through. Any help is welcome. I have such a list, like Santa
So I'm clear, whats actually functional here?
And, whats the compressed version of the wishlist?
I was wondering how you'd deal with all the nuances of very similar requests?
For example
"[Very complex instruction]"
is very similar to
"[Very complex instruction] then filter it by x"
And would probably get detected as the skill.
I think you'd have to save and embed each step aswell as the code
I've not managed to look at the code properly yet so I'm not sure how much further you've got, I was just thinking about it
IMO 'Skills' wouldn't be the same as agent 'tools' or 'actions'.
Any set of steps that can be hardcoded shouldn't be a skill, and anything that is infeasible to hardcode steps should be a skill
Like playing basketball is a skill, but telling the time is not
I think all of this put together would make a really useful agent
You would need to stop it looking for skills while it's already doing one
Unless you have recursive skills
Or would each step itself be a skill?
@burnt gorge thanks your invaluable feedback! It’s really a great thought. We need to think how to narrow the scope of the skills and avoid to generalize its definition too much.
Currently we prefer to consider some shadow help utils code functions or procedure tips as skills
We currently focus on using automatic ways to create skill objects and make it persistent so that it can be easily reused
Your concern is really important
The concept or schema of Skills is not totally the same with tools or actions
Skills here we talk can be created by agents and optimized by human and test agents but tools are normally man crafted
Also actions sound like a function call it means a function selection in the agent’s action space but here our actions to agents are "search skills”,“create a skill”, “test the skill”, and “refactoring skills”
We planed to have a pre-release this weekend. Maybe 2-3 days delay at most
I have finished the overall project but still have more tests and documentation stuff to do
Plz stay tuned 😉
#feature-ideas message
Use local model to look for saved skill and use that if found instead of using the large model to find the skill?
Sounds interesting look forward to seeing how it goes
follow big time🚀🚀🚀
You could make them universal by telling it to generate cross platform code, then people could share them, but how would you deal with where the code contained personal info like a specific file path, and how would you know which parts of the code should be changed when the skill is rerun
Maybe tell it to generate code with placeholders, then when you come to run it replace the placeholders?
Normal skills are functions or classes that can be externally imported
pre-prelease see: https://github.com/timedomain-tech/open-creator
we still have a lot of tests to do
Description: "Build your costomized skill library An open-source LLM tool helps create your tools"
spelling/grammar edits: "An open-source LLM tool for extracting repeatable tasks from your conversations, and saving them into a customized skill library for retrieval."
Thanks, let me update this
thank you for your work! excited to try when i have a minute. a little copy edit is the least i could do 😄
Done!
also, " SreamingStreaming: Stream your function calls"
At top of main description
Build your costomizedcustomized skill library
Yes yes yes
@sullen tide I have some time before I go to neo4j-land to do tests. You said refactor and test agents last.
remember to pull the latest code, there are some bugs fixed
Ok, somebody had an issue with its load function yesterday
I should use pip or repo?
Trying to install repo:
Installing dependencies from lock file
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run `poetry lock [--no-update]` to fix it.
Because open-creator depends on litellm (^0.1.590) which doesn't match any versions, version solving failed.
Fix #1:
pip install litellm
Because open-creator depends on inquirer (^3.1.3) which doesn't match any versions, version solving failed.
and so on, manually installing deps
prompt_toolkit
inquirer
last dep
• Installing annotated-types (0.5.0)
• Downgrading charset-normalizer (3.3.0 -> 3.2.0)
• Installing mypy-extensions (1.0.0)
• Downgrading packaging (23.2 -> 23.1)
• Installing pydantic-core (2.6.3)
• Installing greenlet (2.0.2)
• Installing marshmallow (3.20.1)
• Installing mdurl (0.1.2)
• Installing numpy (1.25.2)
• Installing pydantic (2.3.0)
• Installing typing-inspect (0.9.0)
• Installing dataclasses-json (0.6.0)
• Installing exceptiongroup (1.1.3)
• Downgrading fsspec (2023.9.2 -> 2023.9.1)
• Installing iniconfig (2.0.0)
• Installing langsmith (0.0.40)
• Installing markdown-it-py (3.0.0)
• Installing numexpr (2.8.6)
• Installing pluggy (1.3.0)
• Installing pygments (2.16.1)
• Installing sqlalchemy (2.0.21)
• Installing tenacity (8.2.3)
• Updating huggingface-hub (0.16.4 -> 0.17.2)
• Installing langchain (0.0.297)
• Installing loguru (0.7.2)
• Downgrading openai (0.28.1 -> 0.28.0)
• Installing pytest (7.4.2)
• Installing rich (13.5.3)
• Downgrading tiktoken (0.5.1 -> 0.4.0)
That markdown lib is nifty. I want to rewrite my debugging to use it. Make it all purty and in a fancy getup
from rich.markdown import Markdown
I can't auth with openai. Nothing that uses that will work for me.
openai.error.AuthenticationError: Incorrect API key provided: openinte*******-key. You can find your API key at https://platform.openai.com/account/api-keys.
python3 ./test_tester.py
@sullen tide I hope you don't mind. I was reading your paper. Awesome, by the way, extremely impressive. I think the wording in the abstract could be clearer.
I'll finish later. So is there anything which doesn't require a valid openai key?
There are a few other word choices if you like, just smoother ways of saying things sometimes.
leading to low robustness = leading to fragility for example
Thank you for your valuable suggestion. I am diligently compiling all of your advice, encompassing not only code-related issues but also including matters pertaining to spelling, grammar, and word rephrasing.
I hope you don't mind
Love the paper
So, I don't have an openai key . I tried running some code and got that error. Is this a requirement or is there some way to reconfigure?
Let me give you one
I just did a complete system reinstall and dropped to ubuntu 22.04 branch. 23.04 was causing me CUDA issues. Going to try nix for environmental compartamentalization
Hi everyone, I've been silently following open-interpreter for a while and I wonder if it is overlooked that gpt-3.5-turbo-0613 and gpt-4-0613 are fine-tuned for function calling, cause I can imagine these models would be more suitable for the project.
This is straight from the openai website and think it is still valid: "gpt-3.5-turbo-0613 and gpt-4-0613) have been fine-tuned to both detect when a function should to be called (depending on the input) and to respond with JSON that adheres to the function signature."
Nevermind; #general message