Add PythonREPLToolComponent to tools/__init__.py and create PythonREPLTool.py (#1639)

* re-add --fix

* Add PythonREPLToolComponent to tools/__init__.py and create PythonREPLTool.py

* Refactor PythonREPLToolComponent to use build_status_from_tool in PythonREPLTool.py

* Refactor model_specs imports in ChatLiteLLMSpecs.py

* Refactor imports in various files

* Refactor model_specs imports and class names in AnthropicLLMSpecs.py and AnthropicSpecs.py
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-04-08 16:51:03 -03:00 • committed by GitHub
commit 83c915916d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 245 additions and 243 deletions

View file

@ -6,21 +6,15 @@ import pytest
from langchain_core.documents import Document
from langflow.interface.custom.base import CustomComponent
from langflow.interface.custom.code_parser.code_parser import (
CodeParser,
CodeSyntaxError,
)
from langflow.interface.custom.custom_component.component import (
Component,
ComponentCodeNullError,
)
from langflow.interface.custom.code_parser.code_parser import CodeParser, CodeSyntaxError
from langflow.interface.custom.custom_component.component import Component, ComponentCodeNullError
from langflow.services.database.models.flow import Flow, FlowCreate
code_default = """
from langflow.field_typing import Prompt
from langflow.interface.custom.custom_component import CustomComponent
from langchain.llms.base import BaseLLM
from langflow.field_typing import BaseLanguageModel
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain_core.documents import Document
@ -32,7 +26,7 @@ class YourComponent(CustomComponent):
description: str = "Your description"
field_config = { "url": { "multiline": True, "required": True } }
def build(self, url: str, llm: BaseLLM, template: Prompt) -> Document:
def build(self, url: str, llm: BaseLanguageModel, template: Prompt) -> Document:
response = requests.get(url)
prompt = PromptTemplate.from_template(template)
chain = LLMChain(llm=llm, prompt=prompt)