clear: old code
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import { Queue } from 'bullmq';
|
||||
import { useConfig } from '@kevisual/use-config';
|
||||
const config = useConfig();
|
||||
|
||||
export const connection = {
|
||||
host: config.redis?.host || 'localhost',
|
||||
port: config.redis?.port || 6379,
|
||||
};
|
||||
|
||||
export const quene = new Queue('test', {
|
||||
connection: connection,
|
||||
});
|
||||
@@ -1,38 +0,0 @@
|
||||
import Neode from 'neode';
|
||||
import { useConfig } from '@kevisual/use-config';
|
||||
import neo4j from 'neo4j-driver';
|
||||
|
||||
type NeodeConfig = {
|
||||
uri: string;
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
const { neo4j: neo4jConfig } = useConfig<{ neo4j: NeodeConfig }>('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 () => {
|
||||
// 连接成功
|
||||
// 尝试执行简单的 Cypher 查询以测试连接
|
||||
neode
|
||||
.cypher('RETURN 1', {})
|
||||
.then(() => {
|
||||
console.log('connect neo4j success');
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Failed to connect:', err);
|
||||
});
|
||||
};
|
||||
|
||||
testConnect();
|
||||
@@ -1,30 +0,0 @@
|
||||
import { useConfig } from '@kevisual/use-config';
|
||||
import { Ollama, Message, ChatRequest } from 'ollama';
|
||||
|
||||
const config = useConfig<{ ollama: Ollama['config'] & { model: string } }>();
|
||||
|
||||
const { host, model } = config.ollama;
|
||||
|
||||
export const ollama = new Ollama({ host });
|
||||
|
||||
export type ChatMessage = {
|
||||
content: string;
|
||||
} & Message;
|
||||
|
||||
type ChatOpts = {
|
||||
model?: string;
|
||||
messages?: ChatMessage[];
|
||||
options?: ChatRequest['options'];
|
||||
} & ChatRequest;
|
||||
export const chat = (messages: ChatMessage[], chatOpts?: ChatOpts) => {
|
||||
const { options, stream, ...rest } = chatOpts || {};
|
||||
return ollama.chat({
|
||||
messages,
|
||||
model: model,
|
||||
options: {
|
||||
temperature: 0,
|
||||
...chatOpts?.options,
|
||||
},
|
||||
...rest,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user