Skip to content

Commit

Permalink
Fix typing issues
Browse files Browse the repository at this point in the history
Rename env
  • Loading branch information
yaph committed Jun 28, 2024
1 parent 2830ca3 commit b09b5b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 6 additions & 4 deletions charla/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,26 @@ def available_models() -> None | list[str]:

if model_list := ollama.list()['models']:
return sorted(model_list, key=itemgetter('size'))
return
return None


def generate(model: str, prompt: str, context: list, output: list) -> str | Any:
def generate(model: str, prompt: str, context: list, output: list) -> list:
stream = ollama.generate(model=model, prompt=prompt, context=context, stream=True)

text = ''
for chunk in stream:
if not isinstance(chunk, dict):
continue
if not chunk['done']:
text += chunk['response']
print(chunk['response'], end='', flush=True)

output.append(f'{t_response}\n\n{text}\n')
return chunk['context']
return chunk['context'] if isinstance(chunk, dict) else []


def prompt_session(history: Path) -> PromptSession:
session = PromptSession(message=t_prompt,
session: PromptSession = PromptSession(message=t_prompt,
history=FileHistory(history),
auto_suggest=AutoSuggestFromHistory())

Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ Source = "https://github.com/yaph/charla"
[tool.hatch.version]
path = "charla/__about__.py"

[tool.hatch.envs.dev]
[tool.hatch.envs.charla-dev]
extra-dependencies = ["flake8", "ipdb", "mypy>=1.0.0"]

[tool.hatch.envs.dev.scripts]
[tool.hatch.envs.charla-dev.scripts]
type_check = "mypy --install-types --non-interactive {args:charla tests}"

[tool.hatch.envs.pub.scripts]
release = [
"hatch test",
"hatch build --clean",
Expand Down

0 comments on commit b09b5b0

Please sign in to comment.