Skip to content

VeryInt/GraphQL-AI-Mashup

Repository files navigation

中文说明

GraphQL-AI-Mashup

GraphQL-AI-Mashup is an application that integrates various types of AI interfaces, providing a unified access method through GraphQL, and supporting features such as data streaming (stream).
New feature: Search the web in real time, by DuckDuckGo search engine.

Feature

  • Supports multiple AI services, such as OpenAI, Anthropic Claude, GeminiPro, etc.
  • Uses GraphQL to provide a unified API access, with standardized calling parameters
  • Supports data streaming (stream) functionality
  • Uses DataLoader to optimize API requests, improving performance
  • Can be deployed to Vercel with a single click

AI Support List

AI Default Model Documentation Search web in real time
OpenAI gpt-3.5-turbo Openai Models Not Yet
Cloudflare Workers AI @cf/meta/llama-3-8b-instruct Workers AI Models Not Yet
Azure OpenAI gpt-3.5-turbo Azure Openai Models Yes
GeminiPro gemini-1.0-pro-latest GeminiPro Models Not Yet
Claude claude-3-haiku-20240307 Claude Models Normal: Yes
Stream: No
Moonshot moonshot-v1-8k Moonshot Models Normal: Yes
Stream: No
Groq mixtral-8x7b-32768 Groq Models Not Yet
lingyiwanwu yi-34b-chat-0205 LingYiWanWu Models Not Yet
Baidu Ernie ernie-3.5-4k-0205 Get API KEY & SECRET KEY
Ernie Models
Not Yet
Ali Qwen qwen-turbo Get API KEY
Subscribe to Services
Qwen Models
Yes
Zhipu AI glm-3-turbo API & Token
Zhipu Models
Not Yet

Getting Started

Install Dependencies

npm install

Set API Key Environment Variables

cp .env.example .env

Modify the API keys in the .env file.

Run Development Environment

npm run start

Local Access

http://localhost:4000/

Docker

This project can be deployed via docker, and it comes with its own Dockerfile.

Set API Key Environment Variables

cp .env.example .env

Modify the API keys in the .env file.

Docker Image Build

docker build -t graphql-ai-mashup .    

Docker Run

docker run -dp 4000:4000 graphql-ai-mashup

Local Access

http://localhost:4000/

Deployment

Vercel

Due to Vercel's limitations on the edge runtime, please refer to the project AI-Mashup-Web for deployment.

Cloudflare

This project can be deployed to Cloudflare worker also. Please follow the steps.

Deploy to Cloudflare Workers

Install and configure wrangler

npm install -g wrangler

wrangler login

clone this repository

git clone git@github.com:VeryInt/GraphQL-AI-Mashup.git

Build and deploy your Cloudflare Worker

cd GraphQL-AI-Mashup

wrangler build

wrangler deploy

Usage Examples

The following is an example of using GraphQL to access the GeminiPro interface:

Query

query MyQuery($params: ChatArgs) {
  chat(params: $params) {
    GeminiPro{text}
  }
}

Variables

{
 "params": {
  "messages": [{
    "role": "user",
    "content": "Please tell an 800-word fairy tale"
  }]
 }
}

Stream Query

query MyQuery($params: ChatArgs) {
  chat(params: $params) {
    GeminiProStream @stream
  }
}

ScreenShots

SCR-20240324-mjxc