-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.[:if [:number] is zero or less | ||
:then done! | ||
:else | ||
[:use ./counter | ||
:number=[$ subtract one from [:number]. | ||
just give me the resulting number, no other output]] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[:foo] | ||
[:foo=bar] | ||
[:baz=[:foo][:foo]] | ||
[:baz] | ||
[:use ./dummy] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from config import Config | ||
from provider_config import ProviderConfig | ||
from providers.interactive import InteractiveProvider | ||
from providers.openai import OpenAIProvider | ||
from dotenv import load_dotenv | ||
|
||
import os | ||
|
||
load_dotenv() | ||
|
||
|
||
def load_config(): | ||
"""Load configuration from environment variables""" | ||
provider_config = ProviderConfig() | ||
|
||
provider_config.merge(InteractiveProvider()) | ||
|
||
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") | ||
if OPENAI_API_KEY is not None: | ||
provider_config.merge(OpenAIProvider(api_key=OPENAI_API_KEY)) | ||
|
||
return Config(providers=provider_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from provider import BaseLLMProvider | ||
from provider_config import ProviderConfig | ||
|
||
from typing import AsyncGenerator | ||
|
||
|
||
class InteractiveProvider(ProviderConfig): | ||
"""Provider for the interactive CLI interface""" | ||
|
||
def __init__(self, api_key: str = None, models=None, *args, **kwargs): | ||
super().__init__(self, *args, **kwargs) | ||
self.add( | ||
'interactive', | ||
InteractiveLLMProvider() | ||
) | ||
|
||
|
||
class InteractiveLLMProvider(BaseLLMProvider): | ||
def __init__(self, api_key: str = None, model: str = "gpt-4"): | ||
"""Initialize the provider with API key and model name.""" | ||
super().__init__() | ||
|
||
async def ainvoke(self, prompt: str) -> AsyncGenerator[str, None]: | ||
"""Asynchronously invoke the OpenAI API and yield results in chunks. | ||
Args: | ||
prompt (str): The input prompt for the language model. | ||
Yields: | ||
str: Chunks of the response as they're received. | ||
""" | ||
output = input("[interactive]: " + prompt) | ||
yield output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
import openai | ||
import os | ||
from abc import ABC | ||
from typing import AsyncGenerator | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters