GitXplorerGitXplorer
f

o1-server

public
3 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
a37444693d50297c4cefef410f17814d70f89519

fix async no stream

fflozi00 committed 11 days ago
Unverified
f41ae0e6965d402aa337f0567ba85645c747d98f

deps

fflozi00 committed 11 days ago
Unverified
88efbc64d1088d7c31f4a3751ad10641ff917a2c

make it async all

fflozi00 committed 11 days ago
Unverified
4ca2a4dc9514d400f25b08a12c17c999bcf47681

key

fflozi00 committed 12 days ago
Unverified
ab69aef0081600e8509dc4443054e4c7adc8d9b1

small fixes

fflozi00 committed 12 days ago
Unverified
34157490c35d64b9b44d7f79e8eb112f260c6c2d

fix message_json

fflozi00 committed 12 days ago

README

The README file for this repository.

Step-by-Step Reasoning API

This project provides an API that leverages large language models (LLMs) to perform complex reasoning tasks through a unique step-by-step approach. It uses a feedback-driven system to ensure accuracy and logical consistency. The API is built with FastAPI and is compatible with OpenAI's chat completion endpoint.

Features

  • Step-by-Step Reasoning: Breaks down complex problems into smaller, manageable steps.
  • Feedback Mechanism: Integrates a rewarder model that provides feedback on each step, ensuring correctness.
  • Logical/Analytical and Creative Task Handling: Adapts the problem-solving strategy based on the nature of the task.
  • OpenAI Compatibility: Designed to work with models compatible with the OpenAI API interface.
  • Streaming Support: Offers streaming responses for real-time interaction.

Architecture

The core of the system is based on two main components:

  1. Reasoning Agent: This component generates the step-by-step solution based on the provided prompt and system instructions.
  2. Rewarder Agent: This component evaluates each step generated by the reasoning agent and provides feedback.

The system iteratively generates and evaluates steps until a complete and correct solution is reached.

System Message (SYS_MSG)

The SYS_MSG defines the framework for problem-solving. It outlines the process for both logical/analytical and creative tasks.

For Logical/Analytical Tasks:

  • Problem Decomposition: Clearly state the problem, list given information, constraints, missing information, and the expected output format.
  • Component Analysis: Analyze primary, secondary, and implicit components, including their properties and dependencies.
  • Relationship Mapping: Define direct, indirect, hierarchical, causal, and temporal relationships between components.
  • Comprehension Levels: Understand the problem at literal, contextual, and abstract levels.
  • Solution Development: List assumptions, detail solution steps with validation points, and define boundary conditions.
  • Solution Verification: Ensure logical consistency, completeness, handle edge cases, and check for contradictions.

For Creative Tasks:

  • Focus on originality and innovation.
  • Provide clear reasoning for creative choices.

Rewarder Message (REWARDER)

The REWARDER message defines the role of the rewarder agent, which is to critically rate each step provided by the user. The rewarder only responds with one of three options:

  • Correct: If the step is logically sound.
  • Wrong: If the step contains an error.
  • Too much information in one step. Split this up into smaller parts and think again: If the step contains multiple facts or ideas that should be separated.

Setup

Prerequisites

  • Python 3.9+
  • An OpenAI-compatible API endpoint (e.g., a self-hosted LLM with an OpenAI-compatible interface).
  • An API key for your LLM provider.

Set environment variables:

Create a `.env` file in the project root directory and add the following:

```
OAI_BASE_URL=<your_openai_compatible_api_base_url>
OAI_KEY=<your_api_key>
LLM_NAME=<your_model_name>
```
Replace the placeholders with your actual API base URL, API key, and the name of the LLM you want to use.

Running the API

  1. Start the FastAPI server using uvicorn:

    uvicorn app:app --reload

    This will start the API server on http://0.0.0.0:8000.