File size: 4,170 Bytes
26ff497
 
958be64
26ff497
 
 
 
 
3e2bb45
26ff497
2a47b1a
 
77c7d1d
2a47b1a
 
 
77c7d1d
cea3b9e
8438652
 
 
 
 
 
 
2a47b1a
 
 
 
958be64
ce3f5fc
2a47b1a
 
 
 
 
 
 
 
 
 
 
 
8438652
2a47b1a
8a75147
 
c3dd796
2a47b1a
8438652
2a47b1a
8438652
2a47b1a
8438652
2a47b1a
8438652
2a47b1a
8438652
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a47b1a
8438652
2a47b1a
8438652
2a47b1a
 
 
8438652
 
 
 
 
 
 
2a47b1a
8438652
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a47b1a
8438652
 
 
 
 
 
 
 
 
 
 
 
 
2a47b1a
8438652
2a47b1a
8438652
2a47b1a
8438652
2a47b1a
 
 
 
 
 
 
 
 
 
 
 
8438652
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
title: ArtickBot
emoji: 🚀
colorFrom: yellow
colorTo: red
sdk: docker
pinned: false
license: mit
app_port: 7860
---
---

# ArtickoBot

This project implements a chatbot using FastAPI and a pre-trained language model. The chatbot can generate responses based on user prompts and persona descriptions.

All api docs can be found here https://articko-artickbot.hf.space/docs#/

## Table of Contents

- [Overview](#overview)
- [Endpoints](#endpoints)
  - [/thread/{user_id}](#threaduser_id)
  - [/chat_thread/{user_id}](#chat_threaduser_id)

## Requirements

- Docker
- Hugging Face Spaces

## Usage

### Building the Docker Image

- The application has a Dockerfile that will run automatic and install as well as build the dependencies 

### Running the Docker Container

- The Dockerfile is configured to start uvicorn servers at port: 7860
- The uvicorn can be configured to use multiple workers to process/serve data

### Accessing the API

You can access the API endpoints using a web browser or an HTTP client at `https://articko-artickbot.hf.space/`.

The API endpoints can also be accessed from Localhost using a web browser or an HTTP client at `https://127.0.0.1:7860/`.

If your machine is using proxy servers make sure that the host address of the proxy server is set to host: `127.0.0.1` at Port: `7860` otherwise the requests will be denied

---

## Endpoints

### /thread/{user_id}

Starts a new conversation thread with a provided prompt for a specific user. Remember this uses the ai persona written inside the code, for custom ai persona use endpoint /chat_thread/{user_id}

- **Method**: `POST`
- **Parameters**:
  - `user_id` (str): The unique identifier for the user.
- **Request Body**:
  ```json
  {
    "msg_prompt": "User's message prompt",
    "msg_history": "Previous chat history (optional)"
  }
  ```
- **Responses**:
  - `200 OK`: Successfully started a new conversation thread.
    ```json
    {
      "response": {
        "user_id": "user_id",
        "thread": {
          "thread_id": "unique_thread_id",
          "message_id": "unique_message_id",
          "message": {
            "user": "User's message prompt",
            "assistant": "Model's response"
          }
        }
      }
    }
    ```
  - `400 Bad Request`: If the prompt is not provided.
    ```json
    {
      "detail": "Prompt not provided"
    }
    ```
  - `500 Internal Server Error`: If an unexpected error occurs.
    ```json
    {
      "detail": "Internal Server Error"
    }
    ```

### /chat_thread/{user_id}

Starts a new chat thread with a provided user message prompt and persona description of the AI assistant.

- **Method**: `POST`
- **Parameters**:
  - `user_id` (str): The unique identifier for the user.
- **Request Body**:
  ```json
  {
    "ai_persona": "AI assistant's persona description",
    "msg_prompt": "User's message prompt",
    "msg_history": "Previous chat history (optional)"
  }
  ```
- **Responses**:
  - `200 OK`: Successfully started a new chat thread.
    ```json
    {
      "response": {
        "user_id": "user_id",
        "thread": {
          "thread_id": "unique_thread_id",
          "message_id": "unique_message_id",
          "message": {
            "user": "User's message prompt",
            "assistant": "Model's response"
          }
        }
      }
    }
    ```
  - `400 Bad Request`: If the prompt is not provided.
    ```json
    {
      "detail": "Prompt not provided"
    }
    ```
  - `500 Internal Server Error`: If an unexpected error occurs.
    ```json
    {
      "detail": "Internal Server Error"
    }
    ```

This README provides an overview of Articko Bot and detailed information about its endpoints, including request bodies and responses.

--- 

This should give users a clear understanding of how to interact with the API and what to expect in terms of responses.


For more details on each endpoint, refer to the docstrings within the source code.

## Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

## License

This project is licensed under the [MIT License](LICENSE).

---