CodeLoop¶
pycodeloop.core.codeloop.CodeLoop
¶
Import
You can import the CodeLoop class directly from pycodeloop:
from pycodeloop import CodeLoop, Config
from pycodeloop.providers import GenericProvider
Example
class pycodeloop.core.codeloop.CodeLoop
config = Config(
provider=GenericProvider.from_json("path/to/config.json")
)
flow = CodeLoop(config=config)
flow.run("list the files in this repo and summarize the project")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[Config]
|
Configuration class. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
config |
Config
|
|
agent |
Agent
|
|
session |
Session
|
Conversation history, kept across |
Source code in pycodeloop/core/codeloop.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
agent = Agent(provider=(self.config.provider), tools=(self.config.tools), max_turns=(self.config.max_turns), max_history_turns=(self.config.max_history_turns), **agent_kwargs)
instance-attribute
¶
config = config if config else Config()
instance-attribute
¶
session = Session(system_prompt=(self.agent.system_prompt), cwd=(os.getcwd()))
instance-attribute
¶
__init__(config=None)
¶
Source code in pycodeloop/core/codeloop.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
run(prompt, session_key=None, images=None, cancel_event=None)
¶
Run prompt to completion, keeping history across calls.
Pass session_key with a Config(storage=...) configured to
resume a previous conversation: the session is loaded from
storage before the run (falling back to the in-memory session
on a cache miss) and saved back after.
Source code in pycodeloop/core/codeloop.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |