Coder Social home page Coder Social logo

omniplex's Introduction

hero

Omniplex

Open-Source Perplexity

Website ยท Discord ยท Reddit

๐Ÿšง Under Active Development

Our focus is on establishing core functionality and essential features. As we continue to develop Omniplex, we are committed to implementing best practices, refining the codebase, and introducing new features to enhance the user experience.

Get started

To run the project, modify the code in the Chat component to use the // Development Code.

  1. Fork & Clone the repository
git clone [email protected]:[YOUR_GITHUB_ACCOUNT]/omniplex.git
  1. Install the dependencies
yarn
  1. Fill out secrets in .env.local
BING_API_KEY=
OPENAI_API_KEY=

OPENWEATHERMAP_API_KEY=
ALPHA_VANTAGE_API_KEY=
FINNHUB_API_KEY=
  1. Run the development server
yarn dev
  1. Open http://localhost:3000 in your browser to see the app.

Plugins Development

This is just a hacky way but very easy to implement. We will be adding a more robust way to add plugins in the future. Feel free to understand from the sample plugin we have added.

  1. Update the types in types.ts to include the new plugin data types.
  2. Update the tools api in api to include the new plugin function call.
  3. Update the api.ts in utils file to include the new plugin data.
  4. Update the chatSlice.ts in store to include the new plugin reducer.
  5. Create a new folder in the components directory for the UI of the plugin.
  6. Update the chat.tsx to handle the new plugin in useEffect.
  7. Call the plugin function and return the data as props to source.
  8. Update the source.ts to use the plugin UI.
  9. Lastly Update the data.ts in utils to show in the plugin tab.

Multi-LLM Support: Example

  1. Add the new LLM apiKey in env and add the related npm package.
ANTHROPIC_API_KEY=******
  1. Update the chat in api
import Anthropic from "@anthropic-ai/sdk";
import { OpenAIStream, StreamingTextResponse } from "ai";

const anthropic = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

export const runtime = "edge";

export async function POST(req: Request) {
  const {
    messages,
    model,
    temperature,
    max_tokens,
    top_p,
    frequency_penalty,
    presence_penalty,
  } = await req.json();

  const response = await anthropic.messages.create({
    stream: true,
    model: model,
    temperature: temperature,
    max_tokens: max_tokens,
    top_p: top_p,
    frequency_penalty: frequency_penalty,
    presence_penalty: presence_penalty,
    messages: messages,
  });

  const stream = OpenAIStream(response);
  return new StreamingTextResponse(stream);
}
  1. Update the data in utils
export const MODELS = [
  { label: "Claude 3 Haiku", value: "claude-3-haiku-20240307" },
  { label: "Claude 3 Sonnet", value: "claude-3-sonnet-20240229" },
  { label: "Claude 3 Opus", value: "claude-3-opus-20240229" },
];

Disclaimer

We recently transitioned from the pages directory to the app directory, which involved significant changes to the project structure and architecture. As a result, you may encounter some inconsistencies or rough edges in the codebase.

Roadmap

  • Images & Videos for Search
  • Upload for Vision Model
  • Chat History for Users
  • Shared Chats & Fork
  • Settings for LLMs
  • Custom OG Metadata
  • Faster API Requests
  • Allow Multiple LLMs
  • Plugin Development
  • Function Calling with Gen UI

App Architecture

  • Language: TypeScript
  • Frontend Framework: React
  • State Management: Redux
  • Web Framework: Next.js
  • Backend and Database: Firebase
  • UI Library: NextUI & Tremor
  • CSS Framework: TailwindCSS
  • AI SDK: Vercel AI SDK

Services

  • LLM: OpenAI
  • Search API: Bing
  • Weather API: OpenWeatherMap
  • Stocks API: Alpha Vantage & Finnhub
  • Dictionary API: WordnikFree Dictionary API
  • Hosting & Analytics: Vercel
  • Authentication, Storage & Database: Firebase

Contributing

We welcome contributions from the community! If you'd like to contribute to Openpanel, please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Make your changes and commit them with descriptive messages
  4. Push your changes to your forked repository
  5. Submit a pull request to the main repository

Please ensure that your code follows our coding conventions and passes all tests before submitting a pull request.

License

This project is licensed under the AGPL-3.0 license.

Contact

If you have any questions or suggestions, feel free to reach out to us at Contact.

Happy coding! ๐Ÿš€

omniplex's People

Contributors

bishalsaha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omniplex's Issues

Unhandled Runtime Error - FirebaseError: Firebase: Error (auth/invalid-api-key).

I've followed the install steps, after running yarn dev, adding my open ai api key and then going to http://localhost:3000/ I see the error below on my webpage.

1 of 1 unhandled error
Next.js (14.1.3) out of date [(learn more)](https://nextjs.org/docs/messages/version-staleness)

Unhandled Runtime Error
FirebaseError: Firebase: Error (auth/invalid-api-key).

Source
src\app\AuthWrapper.tsx (12:24) @ getAuth

  10 |
  11 | useEffect(() => {
> 12 |   const auth = getAuth();
     |                      ^
  13 |   const unsubscribe = onAuthStateChanged(auth, async (user) => {
  14 |     if (user) {
  15 |       dispatch(setAuthState(true));

logs

\omniplex>
yarn dev
yarn run v1.22.19
$ next dev
   โ–ฒ Next.js 14.1.3
   - Local:        http://localhost:3000
   - Environments: .env.local

 โœ“ Ready in 2.3s
 โ—‹ Compiling / ...
 โœ“ Compiled / in 12.6s (3307 modules)
redux-persist failed to create sync storage. falling back to noop storage.
 โœ“ Compiled in 1956ms (1448 modules)
 โœ“ Compiled in 219ms (1434 modules)

.env.local

#BING_API_KEY=
OPENAI_API_KEY="sk-xxxxx"

#OPENWEATHERMAP_API_KEY=

#ALPHA_VANTAGE_API_KEY=
#FINNHUB_API_KEY=

Can anyone let me know where I've gone wrong.

Change the prompt to the perplexity prompt

It makes the answer look better:

# Instructions

You are Perplexity, a helpful search assistant trained by Perplexity AI.

# General Instructions

Write an accurate, detailed, and comprehensive response to the user's query located at INITIAL_QUERY.
Additional context is provided as "USER_INPUT" after specific questions.
Your answer should be informed by the provided "Search results".
Your answer must be precise, of high-quality, and written by an expert using an unbiased and journalistic tone.
Your answer must be written in the same language as the query, even if language preference is different.

You MUST cite the most relevant search results that answer the query. Do not mention any irrelevant results.
You MUST ADHERE to the following instructions for citing search results:
- to cite a search result, enclose its index located above the summary with brackets at the end of the corresponding sentence, for example "Ice is less dense than water[1][2]."  or "Paris is the capital of France[1][4][5]."
- NO SPACE between the last word and the citation, and ALWAYS use brackets. Only use this format to cite search results. NEVER include a References section at the end of your answer.
- If you don't know the answer or the premise is incorrect, explain why.
If the search results are empty or unhelpful, answer the query as well as you can with existing knowledge.

You MUST NEVER use moralization or hedging language. AVOID using the following phrases:
- "It is important to ..."
- "It is inappropriate ..."
- "It is subjective ..."

You MUST ADHERE to the following formatting instructions:
- Use markdown to format paragraphs, lists, tables, and quotes whenever possible.
- Use headings level 2 and 3 to separate sections of your response, like "## Header", but NEVER start an answer with a heading or title of any kind.
- Use single new lines for lists and double new lines for paragraphs.
- Use markdown to render images given in the search results.
- NEVER write URLs or links.

# Query type specifications

You must use different instructions to write your answer based on the type of the user's query. However, be sure to also follow the General Instructions, especially if the query doesn't match any of the defined types below. Here are the supported types.

## Academic Research

You must provide long and detailed answers for academic research queries. 
Your answer should be formatted as a scientific write-up, with paragraphs and sections, using markdown and headings.

## Recent News

You need to concisely summarize recent news events based on the provided search results, grouping them by topics.
You MUST ALWAYS use lists and highlight the news title at the beginning of each list item.
You MUST select news from diverse perspectives while also prioritizing trustworthy sources.
If several search results mention the same news event, you must combine them and cite all of the search results. Prioritize more recent events, ensuring to compare timestamps.
You MUST NEVER start your answer with a heading of any kind.

## Weather

Your answer should be very short and only provide the weather forecast. 
If the search results do not contain relevant weather information, you must state that you don't have the answer.

## People

You need to write a short biography for the person mentioned in the query. 
If search results refer to different people, you MUST describe each person individually and AVOID mixing their information together.
NEVER start your answer with the person's name as a header.

## Coding

You MUST use markdown code blocks to write code, specifying the language for syntax highlighting, for example ```bash or ```python
If the user's query asks for code, you should write the code first and then explain it.

## Cooking Recipes

You need to provide step-by-step cooking recipes, clearly specifying the ingredient, the amount, and precise instructions during each step.

## Translation

If a user asks you to translate something, you must not cite any search results and should just provide the translation.

## Creative Writing

If the query requires creative writing, you DO NOT need to use or cite search results, and you may ignore General Instructions pertaining only to search. You MUST follow the user's instructions precisely to help the user write exactly what they need. 

## Science and Math

If the user query is about some simple calculation, only answer with the final result.
Follow these rules for writing formulas:
- Always use \( and\) for inline formulas and\[ and\] for blocks, for example\(x^4 = x - 3 \)
- To cite a formula add citations to the end, for example\[ \sin(x) \] [1][2] or \(x^2-2\) [4].
- Never use $ or $$ to render LaTeX, even if it is present in the user query.
- Never use unicode to render math expressions, ALWAYS use LaTeX.
- Never use the \label instruction for LaTeX.

## URL Lookup

When the user's query includes a URL, you must rely solely on information from the corresponding search result.
DO NOT cite other search results, ALWAYS cite the first result, e.g. you need to end with [1].
If the user's query consists only of a URL without any additional instructions, you should summarize the content of that URL.

## Shopping

If the user query is about shopping for a product, you MUST follow these rules:
- Organize the products into distinct sectors. For example, you could group shoes by style (boots, sneakers, etc.)
- Cite at most 5 search results using the format provided in General Instructions to avoid overwhelming the user with too many options.



Current date: 01:23PM Friday, June 07, 2024

Code workings help

I am not really familiar with typescript but i want to do a change and add features/remake this with js, python, java ect. How do you make allow the ai to search and give it to a response without having an overly long context and function calls(I thought openai didn't support function calls). If you could explain how this works, it would be very helpful.

Ollama support

Would be nice to support self hosted LLMs. It doesn't have to be ollama, but it seems to be fairly easy to interface with.

The streaming response is bugged

Hi,

It seems like the raw response from the OpenAI Streaming Response isn't being handled correctly. Refer to my screenshot below:

image

The raw response from the /api/chat endpoint looks like this:

0:"Richard"
0:" T"
0:"eng"
0:" took"
0:" over"
0:" as"
0:" the"
0:" CEO"
0:" of"
0:" B"
0:"inance"
0:" in"
0:" November"
0:" "
0:"202"
0:"3"
0:","
0:" succeeding"
0:" Chang"
0:"peng"
0:" Zhao"
0:"."
0:" T"
0:"eng"
0:","
0:" who"
0:" h"
0:"ails"
0:" from"
0:" Singapore"
0:","
0:" has"
0:" over"
0:" three"
0:" decades"
0:" of"
0:" financial"
0:" services"
0:" and"
0:" regulatory"
0:" experience"
0:","
0:" having"
0:" held"
0:" key"
0:" positions"
0:" at"
0:" B"
0:"inance"
0:" before"
0:" becoming"
0:" CEO"
0:","
0:" overseeing"
0:" regional"
0:" markets"
0:" beyond"
0:" the"
0:" U"
0:".S"
0:"."
0:" His"
0:" previous"
0:" roles"
0:" include"
0:" Chief"
0:" Regulatory"
0:" Officer"
0:" of"
0:" the"
0:" Singapore"
0:" Exchange"
0:" and"
0:" CEO"
0:" of"
0:" the"
0:" Financial"
0:" Services"
0:" Regulatory"
0:" Authority"
0:" at"
0:" Abu"
0:" Dhabi"
0:" Global"
0:" Market"
0:"."
0:" T"
0:"eng"
0:" is"
0:" focused"
0:" on"
0:" ass"
0:"uring"
0:" B"
0:"inance"
0:"'s"
0:" users"
0:" regarding"
0:" the"
0:" company"
0:"'s"
0:" financial"
0:" strength"
0:" and"
0:" security"
0:"{"
0:"1"
0:"}{"
0:"2"
0:"}."

Docker Compose example

Would be nice to have a docker compose for quick startup of the app and all its dependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.