GitXplorerGitXplorer
f

o1-server

public
3 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
3143460626a06bab96712058981bfa4977d4ee85

Update README.md

fflozi00 committed 12 days ago
Verified
3ffede11d6452fa31c9992bd2df204f3e65c651d

Update app.py

fflozi00 committed 12 days ago
Verified
30152661216402aadf34b8c41aba55fc1d898778

Update app.py

fflozi00 committed 12 days ago
Verified
e5d8b614d876bb89633d75732470cdd5a59235d0

Create app.py

fflozi00 committed 12 days ago
Verified
6b32e447e3f09050be09e2bd9a3cf00b361f02ab

Initial commit

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.