parent
978637a1c1
commit
c669cbb12b
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="old-tom" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Pipenv (llmFunctionCallDemo)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/llmFunctionCallDemo.iml" filepath="$PROJECT_DIR$/.idea/llmFunctionCallDemo.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2025/3/29 08:49
|
||||
# @Author : old-tom
|
||||
# @File : llm_config
|
||||
# @Project : llmFunctionCallDemo
|
||||
# @Desc : llm配置文件解析
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel
|
||||
import toml
|
||||
|
||||
# 默认配置文件名
|
||||
DEFAULT_CONF_NAME = 'env.toml'
|
||||
path = os.path.dirname(__file__)
|
||||
path = os.path.dirname(path)
|
||||
# 默认配置文件位置
|
||||
DEFAULT_CONF_PATH = os.path.join(path, DEFAULT_CONF_NAME)
|
||||
|
||||
|
||||
class ConfigNotFoundError(Exception):
|
||||
"""
|
||||
配置不存在异常
|
||||
"""
|
||||
|
||||
def __init__(self, msg):
|
||||
Exception.__init__(self, msg)
|
||||
|
||||
|
||||
class LLMConf(BaseModel):
|
||||
api_key: str
|
||||
model: str
|
||||
base_url: str
|
||||
max_tokens: int
|
||||
temperature: float
|
||||
streaming: bool = True
|
||||
|
||||
|
||||
class LLMConfigLoader(object):
|
||||
@staticmethod
|
||||
def load(item_name, conf_path: str = DEFAULT_CONF_PATH) -> LLMConf:
|
||||
"""
|
||||
校验并加载配置
|
||||
:return:
|
||||
"""
|
||||
if not os.path.isfile(conf_path):
|
||||
raise ConfigNotFoundError(f'模型配置文件{DEFAULT_CONF_NAME}不存在')
|
||||
conf = toml.load(conf_path)
|
||||
return LLMConf(**conf[item_name])
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2025/3/16 16:38
|
||||
# @Author : old-tom
|
||||
# @File : basic_tool
|
||||
# @Project : llmFunctionCallDemo
|
||||
# @Desc :
|
||||
|
||||
import json
|
||||
from langchain_core.tools import tool
|
||||
|
||||
@tool
|
||||
def get_current_weather(location: str, unit: str = "celsius") -> str:
|
||||
"""Get the current weather in a given location
|
||||
|
||||
Args:
|
||||
location (str): location of the weather.
|
||||
unit (str): unit of the tempuature.
|
||||
|
||||
Returns:
|
||||
str: weather in the given location.
|
||||
"""
|
||||
|
||||
weather_info = {
|
||||
"location": location,
|
||||
"temperature": "27",
|
||||
"unit": unit,
|
||||
"forecast": ["sunny", "windy"],
|
||||
}
|
||||
return json.dumps(weather_info)
|
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Time : 2025/3/29 20:49
|
||||
# @Author : old-tom
|
||||
# @File : log_conf
|
||||
# @Project : llmFunctionCallDemo
|
||||
# @Desc : 日志配置
|
||||
|
||||
import sys
|
||||
import os
|
||||
from loguru import logger
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 日志输出路径
|
||||
LOG_PATH = os.path.join(BASE_DIR, r'logout/logout.log')
|
||||
|
||||
|
||||
class Logger(object):
|
||||
def __init__(self):
|
||||
self.logger = logger
|
||||
self.logger.remove()
|
||||
self.logger.add(sys.stdout,
|
||||
format="<green>{time:YYYY-MM-DD HH:mm:ss}</green> | " # 颜色>时间
|
||||
"{process.name} | " # 进程名
|
||||
"{thread.name} | " # 进程名
|
||||
"<cyan>{module}</cyan>.<cyan>{function}</cyan>" # 模块名.方法名
|
||||
":<cyan>{line}</cyan> | " # 行号
|
||||
"<level>{level}</level>: " # 等级
|
||||
"<level>{message}</level>", # 日志内容
|
||||
)
|
||||
# 输出到文件的格式,注释下面的add',则关闭日志写入
|
||||
self.logger.add(LOG_PATH, level='DEBUG',
|
||||
format='{time:YYYY-MM-DD HH:mm:ss} - ' # 时间
|
||||
"{process.name} | " # 进程名
|
||||
"{thread.name} | " # 进程名
|
||||
'{module}.{function}:{line} - {level} -{message}', # 模块名.方法名:行号
|
||||
rotation="10 MB")
|
||||
|
||||
def get_logger(self):
|
||||
return self.logger
|
||||
|
||||
|
||||
log = Logger().get_logger()
|
@ -1,33 +1,55 @@
|
||||
aiohappyeyeballs==2.6.1
|
||||
aiohttp==3.11.14
|
||||
aiosignal==1.3.2
|
||||
annotated-types==0.7.0
|
||||
anyio==4.8.0
|
||||
async-timeout==4.0.3
|
||||
attrs==25.3.0
|
||||
certifi==2025.1.31
|
||||
charset-normalizer==3.4.1
|
||||
dataclasses-json==0.6.7
|
||||
distro==1.9.0
|
||||
exceptiongroup==1.2.2
|
||||
frozenlist==1.5.0
|
||||
h11==0.14.0
|
||||
httpcore==1.0.7
|
||||
httpx==0.28.1
|
||||
httpx-sse==0.4.0
|
||||
idna==3.10
|
||||
jiter==0.9.0
|
||||
jsonpatch==1.33
|
||||
jsonpointer==3.0.0
|
||||
langchain==0.3.21
|
||||
langchain-community==0.3.20
|
||||
langchain-core==0.3.45
|
||||
langchain-openai==0.3.8
|
||||
langchain-text-splitters==0.3.7
|
||||
langsmith==0.3.15
|
||||
marqo==3.11.0
|
||||
marshmallow==3.26.1
|
||||
multidict==6.2.0
|
||||
mypy-extensions==1.0.0
|
||||
numpy==2.2.4
|
||||
openai==1.66.3
|
||||
orjson==3.10.15
|
||||
packaging==24.2
|
||||
propcache==0.3.1
|
||||
pydantic==2.10.6
|
||||
pydantic-settings==2.8.1
|
||||
pydantic_core==2.27.2
|
||||
python-dotenv==1.1.0
|
||||
PyYAML==6.0.2
|
||||
regex==2024.11.6
|
||||
requests==2.32.3
|
||||
requests-toolbelt==1.0.0
|
||||
sniffio==1.3.1
|
||||
SQLAlchemy==2.0.40
|
||||
tenacity==9.0.0
|
||||
tiktoken==0.9.0
|
||||
toml==0.10.2
|
||||
tqdm==4.67.1
|
||||
typing-inspect==0.9.0
|
||||
typing_extensions==4.12.2
|
||||
urllib3==2.3.0
|
||||
yarl==1.18.3
|
||||
zstandard==0.23.0
|
||||
|
Loading…
Reference in new issue