Move to src dir usage (#99)

This commit is contained in:
Greyson LaLonde
2024-01-10 09:39:36 -05:00
committed by GitHub
parent a944cfc8d0
commit 155368be3b
22 changed files with 17 additions and 6 deletions

6
poetry.lock generated
View File

@@ -870,13 +870,13 @@ extended-testing = ["aiosqlite (>=0.19.0,<0.20.0)", "aleph-alpha-client (>=2.15.
[[package]]
name = "langchain-core"
version = "0.1.8"
version = "0.1.9"
description = "Building applications with LLMs through composability"
optional = false
python-versions = ">=3.8.1,<4.0"
files = [
{file = "langchain_core-0.1.8-py3-none-any.whl", hash = "sha256:f4d1837d6d814ed36528b642211933d1f0bd84e1eff361f4630a8c750acc27d0"},
{file = "langchain_core-0.1.8.tar.gz", hash = "sha256:93ab72f5ab202526310fad389a45626501fd76ecf56d451111c0d4abe8183407"},
{file = "langchain_core-0.1.9-py3-none-any.whl", hash = "sha256:1dd45aec185ce3afb1c19fb2e88cdbc19fafa7ae929d8107799a7c82ef69ea9f"},
{file = "langchain_core-0.1.9.tar.gz", hash = "sha256:4b51fdbdbc06027c26ea89a6da809cae2e404c9daa95dc6c10e3eae383d8ea6a"},
]
[package.dependencies]

View File

@@ -5,6 +5,10 @@ version = "0.1.24"
description = "Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks."
authors = ["Joao Moura <joaomdmoura@gmail.com>"]
readme = "README.md"
packages = [
{ include = "crewai", from = "src" },
]
[tool.poetry.urls]
Homepage = "https://github.com/joaomdmoura/crewai"

View File

@@ -3,7 +3,8 @@ import os
from typing import ClassVar, Dict, Optional
from langchain.prompts import PromptTemplate
from pydantic import BaseModel, Field, PrivateAttr, model_validator, ValidationError
from pydantic import BaseModel, Field, PrivateAttr, ValidationError, model_validator
class Prompts(BaseModel):
"""Manages and generates prompts for a generic agent with support for different languages."""
@@ -24,7 +25,9 @@ class Prompts(BaseModel):
with open(prompts_path, "r") as f:
self._prompts = json.load(f)["slices"]
except FileNotFoundError:
raise ValidationError(f"Prompt file for language '{self.language}' not found.")
raise ValidationError(
f"Prompt file for language '{self.language}' not found."
)
except json.JSONDecodeError:
raise ValidationError(f"Error decoding JSON from the prompts file.")
return self
@@ -45,6 +48,10 @@ class Prompts(BaseModel):
def _build_prompt(self, components: [str]) -> str:
"""Constructs a prompt string from specified components."""
prompt_parts = [self._prompts[component] for component in components if component in self._prompts]
prompt_parts = [
self._prompts[component]
for component in components
if component in self._prompts
]
prompt_parts.append(self.SCRATCHPAD_SLICE)
return PromptTemplate.from_template("".join(prompt_parts))

View File