feat: add neo4j and prompt and prompt-graph

This commit is contained in:
2024-09-26 01:18:43 +08:00
parent 25c055b490
commit 229ad7caed
12 changed files with 441 additions and 74 deletions

View File

@@ -1,17 +1,26 @@
import Neode from 'neode';
import { useConfig } from '@abearxiong/use-config';
import neo4j from 'neo4j-driver';
type NeodeConfig = {
uri: string;
username: string;
password: string;
};
const { neo4j } = useConfig<{ neo4j: NeodeConfig }>('neo4j');
const { neo4j: neo4jConfig } = useConfig<{ neo4j: NeodeConfig }>('neo4j');
const { uri, username, password } = neo4j;
const { uri, username, password } = neo4jConfig;
// 设置连接配置
// const neode = new Neode('bolt://localhost:7687', 'neo4j', 'your_password');
export const neode = new Neode(uri, username, password);
// 创建与 Neo4j 数据库的连接
export const neoDriver = neo4j.driver(
uri, // 数据库地址
neo4j.auth.basic(username, password), // 用户名和密码
);
export const getSession = () => {
return neoDriver.session();
};
const testConnect = async () => {
// 连接成功

View File

@@ -3,7 +3,7 @@ import { Ollama, Message, ChatRequest } from 'ollama';
const config = useConfig<{ ollama: Ollama['config'] & { model: string } }>();
const { host } = config.ollama;
const { host, model } = config.ollama;
export const ollama = new Ollama({ host });
@@ -20,7 +20,7 @@ export const chat = (messages: ChatMessage[], chatOpts?: ChatOpts) => {
const { options, stream, ...rest } = chatOpts || {};
return ollama.chat({
messages,
model: config.model,
model: model,
options: {
temperature: 0,
...chatOpts?.options,