This commit is contained in:
2025-03-02 15:25:21 +08:00
parent 95da1cd5a8
commit bb9a9ee201
6 changed files with 32 additions and 128 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,5 @@
# ---> Python
backend/psk-graphrag
backend/evaluate/eval_rag_dataset/*
backend/history/*
# Byte-compiled / optimized / DLL files

22
backend/.env.example Executable file
View File

@@ -0,0 +1,22 @@
"""
Author: Yutang LI
Institution: SIAT-MIC
Contact: yt.li2@siat.ac.cn
"""
# Model Config
OPENAI_API_KEY = ""
OPENAI_BASE_URL = ""
# MODEL = "chatgpt-4o-latest"
MODEL = "gpt-4o-2024-11-20"
# MODEL = "deepseek-chat"
# path
CODING_DIR = ".coding"
# MinIO
MINIO_ENDPOINT=
INTERNAL_MINIO_ENDPOINT=
MINIO_ACCESS_KEY=
MINIO_SECRET_KEY=
MINIO_BUCKET=

View File

@@ -19,6 +19,8 @@ SILENT = True # 关闭嵌套智能体的输出
STREAM = True # stream on console
CACHE = None # None 就是关闭 41是默认值开启
GRAPH_RAG = "/root/data50T/LYT/matagent/backend/psk-graphrag/settings.yaml"
WORK_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".coding")
if not os.path.exists(WORK_DIR):
os.mkdir(WORK_DIR)

View File

@@ -7,7 +7,8 @@ from autogen_agentchat.messages import AgentEvent, ChatMessage, TextMessage, Too
from autogen_agentchat.teams import SelectorGroupChat, RoundRobinGroupChat, Swarm
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from backend.constant import MODEL, OPENAI_API_KEY, OPENAI_BASE_URL
from backend.constant import MODEL, OPENAI_API_KEY, OPENAI_BASE_URL, GRAPH_RAG
from autogen_ext.tools.graphrag import GlobalSearchTool
from backend.tools import hybird_retrieval_from_knowledge_base, search_from_oqmd_by_composition
from backend.custom import SocietyOfMindAgent
@@ -47,6 +48,7 @@ def create_scientist_team(user_input_func: Callable[[str, Optional[CancellationT
handoffs=["Synthesis_Scientist", "Structure_Scientist", "Property_Scientist", "Application_Scientist"]
)
graph_rag_search = GlobalSearchTool.from_settings(settings_path=GRAPH_RAG)
synthesis_agent = AssistantAgent(
"Synthesis_Scientist",
description="An experienced materials scientist agent who is particularly good at coming up with detailed synthesis schemes, and should be called when the task around a material synthesis topic.",
@@ -86,7 +88,7 @@ def create_scientist_team(user_input_func: Callable[[str, Optional[CancellationT
Always handoff back to Scientist_Admin when synthesis scheme is complete.
Let's think step by step and answer with {lang}:
""",
tools=[hybird_retrieval_from_knowledge_base],
tools=[hybird_retrieval_from_knowledge_base, search_from_oqmd_by_composition, graph_rag_search],
reflect_on_tool_use=True,
handoffs=["Scientist_Admin"]
)
@@ -106,7 +108,7 @@ def create_scientist_team(user_input_func: Callable[[str, Optional[CancellationT
Always handoff back to Scientist_Admin when response is complete.
Answer with {lang}:
""",
tools=[hybird_retrieval_from_knowledge_base],
tools=[hybird_retrieval_from_knowledge_base, search_from_oqmd_by_composition, graph_rag_search],
reflect_on_tool_use=True,
handoffs=["Scientist_Admin"]
)
@@ -127,7 +129,7 @@ def create_scientist_team(user_input_func: Callable[[str, Optional[CancellationT
Always handoff back to Scientist_Admin when response is complete.
Answer with {lang}:
""",
tools=[hybird_retrieval_from_knowledge_base],
tools=[hybird_retrieval_from_knowledge_base, search_from_oqmd_by_composition, graph_rag_search],
reflect_on_tool_use=True,
handoffs=["Scientist_Admin"]
)
@@ -148,7 +150,7 @@ def create_scientist_team(user_input_func: Callable[[str, Optional[CancellationT
Always handoff back to Scientist_Admin when response is complete.
Answer with {lang}:
""",
tools=[hybird_retrieval_from_knowledge_base],
tools=[hybird_retrieval_from_knowledge_base, search_from_oqmd_by_composition, graph_rag_search],
reflect_on_tool_use=True,
handoffs=["Scientist_Admin"]
)

108
default
View File

@@ -1,108 +0,0 @@
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
# HTTP location block
location / {
proxy_pass http://127.0.0.1:8000; # Uvicorn <20><><EFBFBD>еĵ<D0B5>ַ<EFBFBD>Ͷ˿<CDB6>
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /chat {
proxy_pass http://127.0.0.1:8000; # Uvicorn <20><><EFBFBD>еĵ<D0B5>ַ<EFBFBD>Ͷ˿<CDB6>
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# <20><><EFBFBD><EFBFBD> WebSocket <20><><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

14
test.py
View File

@@ -1,14 +0,0 @@
# import json
# import os
# with open("/root/data50T/LYT/matagent/_backend/history/b872c00a-990f-4099-a830-2bc8f7b30d11/team_history.json") as f:
# data = json.load(f)
# for message in data:
# if isinstance(message['content'], str):
# print(f"----------------{message['source']}----------------\n {message['content']}")
data = """
'Liquid exfoliation is a synthesis technique used to break apart layered materials, such as graphite, MoS₂, and various clays, into individual, atomically thin nanosheets. In liquid exfoliation, the bulk layered material is dispersed in a liquid medium, where its weak van der Waals forces holding the layers together can be overcome. This is achieved through several methods: oxidation, which modifies the material chemically; ion intercalation or exchange, where ions are inserted between the layers to increase spacing; and surface passivation by solvents, which helps to weaken the interlayer attractions. The combination of these methods allows the layered crystals to be delaminated into high-aspect ratio nanosheets with a large surface area, making them suitable for creating thin films, composites, and other advanced materials.'
"""
print(data)