Begin work on agent core

This commit is contained in:
2024-10-27 10:35:05 +01:00
parent a110140d5b
commit d922c12556
9 changed files with 330 additions and 76 deletions

View File

@@ -1,4 +1,5 @@
from threading import Thread
from typing import Iterator
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, TextIteratorStreamer
import torch
@@ -44,7 +45,7 @@ class LlmEngine:
return_full_text=False,
)
def infer(self, system_prompt: str, main_context: str) -> TextIteratorStreamer:
def infer(self, system_prompt: str, main_context: str) -> Iterator[str]:
"""
Run inference using the system prompt and main context, while validating actions against the provided XML schema.
@@ -53,7 +54,7 @@ class LlmEngine:
main_context: The main context string after templating
Returns:
TextIteratorStreamer: An iterator that yields the generated text.
Iterator[str]: An iterator that yields the generated text.
"""
messages = [
{"role": "system", "content": system_prompt},