Skip to content

Commit

Permalink
feat: add eino assistant as example (#3)
Browse files Browse the repository at this point in the history
* feat: add eino assistant as example
  • Loading branch information
kuhahalong authored Jan 20, 2025
1 parent 7578934 commit d5636b2
Show file tree
Hide file tree
Showing 56 changed files with 8,499 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ output/*

# Vscode files
.vscode

.DS_Store
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/cloudwego/eino-examples

go 1.22.0

toolchain go1.22.1
toolchain go1.22.10

require (
github.com/cloudwego/eino v0.3.7
Expand Down
18 changes: 18 additions & 0 deletions quickstart/eino_assistant/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ark model: https://console.volcengine.com/ark
# 必填,
# 火山云方舟 ChatModel 的 Endpoint ID
export ARK_CHAT_MODEL=""
# 火山云方舟 向量化模型的 Endpoint ID
export ARK_EMBEDDING_MODEL=""
# 火山云方舟的 API Key
export ARK_API_KEY=""

# langfuse: https://cloud.langfuse.com/
# 下面两个环境变量如果为空,则不开启 langfuse callback
# Langfuse Project 的 Public Key
export LANGFUSE_PUBLIC_KEY=""
# Langfuse Project 的 Secret Key。 注意,Secret Key 仅可在被创建时查看一次
export LANGFUSE_SECRET_KEY=""

# Redis Server 的地址,不填写时,默认是 localhost:6379
export REDIS_ADDR=
166 changes: 166 additions & 0 deletions quickstart/eino_assistant/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea/
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### GoLand template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

.vscode/
log/
cmd/einoagent/data/
__debug_bin*
/einoagent
.DS_Store
/data/
/einoagent
42 changes: 42 additions & 0 deletions quickstart/eino_assistant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## 说明

### docker 启动 redis 作为向量数据库

```bash
docker-compose up -d
# 可以在 http://127.0.0.1:8001 看到 redis 的 web 界面
# redis 监听在 127.0.0.1:6379, 使用 redis-cli ping 可测试
```

### 环境变量

所需的大模型和 API Key.
豆包大模型地址: https://console.volcengine.com/ark/region:ark+cn-beijing/model
> ChatModel 推荐: [Doubao-pro-4k (functioncall)](https://console.volcengine.com/ark/region:ark+cn-beijing/model/detail?Id=doubao-pro-4k)
> EmbeddingModel 推荐: [Doubao-embedding-large](https://console.volcengine.com/ark/region:ark+cn-beijing/model/detail?Id=doubao-embedding-large)
> 进入页面后点击 `推理` 按钮,即可创建按量计费的模型接入点,对应的 `ep-xxx` 就是所需的 model 名称
```bash
export ARK_API_KEY=xxx
export ARK_CHAT_MODEL=xxx
export ARK_EMBEDDING_MODEL=xxx
```

### 启动 eino agent server

```bash
# 为了使用 data 目录,需要在 eino_assistant 目录下执行指令
go run cmd/einoagent/*.go
```

### 访问

访问 http://127.0.0.1:8080/ 即可看到效果

### 命令行运行 index (可选)

```bash
# 因示例的Markdown文件存放在 cmd/knowledgeindexing/eino-docs 目录,代码中指定了相对路径 ./eino-docs,所以需在 cmd/knowledgeindexing 运行指令
cd cmd/knowledgeindexing
go run main.go
```
Loading

0 comments on commit d5636b2

Please sign in to comment.