GithubHelp home page GithubHelp logo

nimbleboxai / chainfury Goto Github PK

View Code? Open in Web Editor NEW
404.0 404.0 41.0 12.97 MB

๐Ÿฆ‹ Production grade chaining engine behind TuneChat. Self host today!

Home Page: https://nimbleboxai.github.io/ChainFury/

License: Apache License 2.0

Python 61.23% HTML 0.08% JavaScript 2.96% TypeScript 34.57% CSS 0.33% Dockerfile 0.25% Shell 0.26% Makefile 0.14% Batchfile 0.18%
chat-applications chatbot-framework hacktoberfest hacktoberfest2023 large-language-models llm prompt-engineering

chainfury's People

Contributors

chanh-1 avatar cshubhamrao avatar ishan121028 avatar priya314 avatar priyasridharandav avatar rohanpooniwala avatar vgulerianb avatar vinujaaa avatar yashbonde 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  avatar  avatar  avatar  avatar

chainfury's Issues

Docker builds broken - failed to update submodules

Hello, just went to try out this project and found that the docker builds appear to be broken:

 docker-compose --profile chainfury build chainfury

[+] Building 7.1s (1/1) FINISHED                                                                                                        docker:default
 => ERROR [chainfury internal] load git source https://github.com/NimbleBoxAI/ChainFury.git#main                                                  7.0s
------
 > [chainfury internal] load git source https://github.com/NimbleBoxAI/ChainFury.git#main:
0.031 Initialized empty Git repository in /var/lib/docker/overlay2/kmi7v6n43ang13uzaq6g3rjro/diff/
0.711 e7042bfab103e005478225775f9a31d3ed64529e  refs/heads/main
1.090 From https://github.com/NimbleBoxAI/ChainFury
1.090  * [new branch]      main       -> main
1.090  * [new branch]      main       -> origin/main
4.789 Submodule 'cf_internal' (https://github.com/NimbleBoxAI/cf_internal.git) registered for path 'cf_internal'
4.791 Cloning into '/var/lib/docker/overlay2/6tdttt9znbsg1g44v8zpu0gzd/diff/cf_internal'...
5.098 fatal: could not read Username for 'https://github.com': terminal prompts disabled
5.100 fatal: clone of 'https://github.com/NimbleBoxAI/cf_internal.git' into submodule path '/var/lib/docker/overlay2/6tdttt9znbsg1g44v8zpu0gzd/diff/cf_internal' failed
5.100 Failed to clone 'cf_internal'. Retry scheduled
5.102 Cloning into '/var/lib/docker/overlay2/6tdttt9znbsg1g44v8zpu0gzd/diff/cf_internal'...
5.408 fatal: could not read Username for 'https://github.com': terminal prompts disabled
5.410 fatal: clone of 'https://github.com/NimbleBoxAI/cf_internal.git' into submodule path '/var/lib/docker/overlay2/6tdttt9znbsg1g44v8zpu0gzd/diff/cf_internal' failed
5.410 Failed to clone 'cf_internal' a second time, aborting
------
failed to solve: failed to read dockerfile: failed to update submodules for https://github.com/NimbleBoxAI/ChainFury.git: exit status 1

I think the key thing here is:

5.098 fatal: could not read Username for 'https://github.com': terminal prompts disabled

I suspect the docker image perhaps isn't setup to be run non-interactively?

How to create plugins?

I have a simple question, where can I add code so people can log the responses back to their systems. Ex. I want to log a few things to the NBX-LMAOv4 via nbox (probably).

Here's the structure I have followed elsewhere:

./
โ”œโ”€โ”€ plugins/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ graphana.py                # file for those that can do it in a file 
โ”‚   โ”œโ”€โ”€ nbx/                       # folder for those who need it, doesn't matter
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ lmao_logger.py
โ”‚   โ”‚   โ””โ”€โ”€ auth.py
โ”‚   โ””โ”€โ”€ plugin_amazon.py
โ””โ”€โ”€ server/
    โ”œโ”€โ”€ __init__.py
    โ””โ”€โ”€ plugins/                   # A separate system for managing plugins
        โ”œโ”€โ”€ plugin_middleware.py   # Contains the fastAPI middleware
        โ”œโ”€โ”€ plugin_handler.py      # Configurable handler initialised during start sequence
        โ””โ”€โ”€ plugin_base.py         # Interface for plugin builders

Requirements

Some requirements from server:

  • Anyone should be able to build a plugin by implementing the interface
  • User should be able to tell which plugins to activate during init, CLI / config for this?

Some requirements from plugins:

  • Any import issues should (ideally) be resolved during startup, you wouldn't want your plugin to crash someone else's server. That's evil!

Dummy Code?

Here's the code for:

from server.plugins.plugin_base import PluginBase, Event, PluginHandler

class GraphanaPlugin(PluginBase):
    name: str = "graphana-v1"
    import_name: str = "plugins.graphana"
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.graphana_logger = GraphanaLogger()

    def _parse_to_grphan(self, event: Event) -> str:
        # do something with the event
        return "graphana string"

    def handle_event(self, event: Event, handler: PluginManager):
        # do something with the event
        if event.type == "something-useful":
            self.graphana_logger.log(
                self._parse_to_grphan(event)
            )

        # or make a change the server via plugin handler
        action = some_function(event)
        if action == "disable_key":
            handler.disable_key(action.data)

When starting from CLI (or somewhere from config):

python3 -m server.py --plugins="['graphana-v1','nbx-lmao-v1']"

Where put plugins?

In each function where we provide the ability to have a plugin, we can add a plugin_handler argument, which is an instance of PluginHandler (or something similar). This will allow the plugin to interact with the server.

# file: server/commons/langflow_utils.py
import plugin_handler

def get_prompt(chatbot_id: str, prompt: Prompt, db: Session):
    # I would like to capture this data
    plugin_handler.handle_event(
        Event(
            type="get_prompt",
            data={
                "chatbot_id": chatbot_id,
                "prompt": prompt,
                "db": db
            }
        )
    )
    ...

You might be wondering why bother with the above one because you can use the APIs for it. But what if I want to capture some other part of the system, like the template API?

# file: server/api/template.py
import plugin_handler

@template_router.get("/template/{template_id}", response_model=Template)
def get_template_by_id(...):
    # I would also like to capture this data
    plugin_handler.handle_event(
        Event(
            type="get_template",
            data={
                "template_id": template_id,
            }
        )
    )

I can then join both of those from my end, and do something with it.

I can help building the interface and all. Let me know what you guys think!

Screenshots please!

I would love to see what this UI looks like before I go through the trouble of setting it up. Thanks!

Link to try ChainFury in Readme not working

This is the URL the link to try ChainFury goes to https://alpaca-irregulardensity.byocawsv0.on.nimblebox.ai/

I found another URL from your site to try it but the "Create Account" seems to be broken at least with the information I am using to SignUp here https://chainfury.nbox.ai/ui/signup

I am currently working on trying to customize LangFlow to use all Typescript (replacing the need for the python backend) so I can use it all within a single Next App but I'm at early stages. If your project seems like a better path to get up and running I might fork and contribute.

How do I use ChainFury with SSL?

Hey,
sorry for this newbie question... I set up the Docker container on a VPS and have created a Let's Encrypt certificate.

Accessing the web interface with HTTP works perfectly but with HTTPS, I get an error that the site cannot provide a secure connection. It says: "domain.com sent an invalid response"

Is there a setting I need to update in the config of ChainFury or is this a hosting-related (Hetzner) issue?

Cannot start server because of langflow.

file "commons/langflow_utils.py" requires langflow installed. And so I cannot run the server:

(venv) โžœ  server git:(main) โœ— uvicorn app:app --log-level=debug --host 0.0.0.0 --port 8000
2023-04-23 11:35:00,440 - commons.config - INFO - Using sqlite database
2023-04-23 11:35:00,449 - commons.config - INFO - Database opened successfully
Traceback (most recent call last):
  File "/opt/homebrew/bin/uvicorn", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/homebrew/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/main.py", line 407, in main
    run(
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/main.py", line 575, in run
    server.run()
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/server.py", line 67, in serve
    config.load()
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/config.py", line 479, in load
    self.loaded_app = import_from_string(self.app)
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/importer.py", line 24, in import_from_string
    raise exc from None
  File "/opt/homebrew/lib/python3.10/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
  File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/yashbonde/Desktop/ai/repos/ChainFury/server/./app.py", line 17, in <module>
    from api.langflow import router as langflow_router
  File "/Users/yashbonde/Desktop/ai/repos/ChainFury/server/./api/langflow.py", line 2, in <module>
    from langflow.interface.types import build_langchain_types_dict
ModuleNotFoundError: No module named 'langflow'

Requirements has this line commented out:

# langflow==0.0.54

Even when I installed the above version manually I get the same error. When I installed the latest version langflow==0.0.57 I get the same error.

Can't fix it myself, please help.

how to add custom tools/agents

could the existing tool implementation be extended to add new types of tools for drag and drop, or does it need extensive work for each tool. if you add that in readme documentation, how to add custom tools/agents/chains, developers can contribute PRs

Problem signing up

After signing up, I return to the login page. With out any hint if it was successful or that I would receive an email.

When I try to sign in with the credentials I signed up with I get an 'invalid credentials' comment.

I didnt receive any email.
Email should have been sent to *@skiff.com
Maybe this is the problem?

Demo site is up and running now.
Sign up-
https://chainfury.nbox.ai/ui/signup

Originally posted by @chanh-1 in > #72 (comment)

Trying to run the GUI

I installed using pip commands (tried WSL2 and Windows 11)
I just get:

 python3 -m chainfury_server
/usr/bin/python3: No module named chainfury_server.__main__; 'chainfury_server' is a package and cannot be directly executed

Any idea what am I doing wrong? all the dependencies seem to downloaded.

Add support for Vector DB

Adding support for storage would give chainfury an infinite breathing room for storing and processing information.

We plan to add the following in the first iteration:

  • qdrant
  • pinecone
  • milvus

I am planning that it will follow the same kind of registry pattern that we follow across the chainfury. Note that I am giving a very high level overview here so focus more on the interface not the implementation.

class CFDB:
  # some constants
  VECTOR_TYPE = "vector"
  SQL_TYPE = "sql"

  def read(self, *args, **kwargs) -> Dict[str, List[str]]
  def write(self, *args, **kwargs) -> bool?

  # ser/deser
  def from_dict(self, data: Dict[str, Any]) -> CFDB
  def to_dict(self) -> Dict[str, Any]
  def from_json(self, x: str) -> CFDB
  def to_json(self) -> str

class DBRegistry:
  def register(self, name: str, db_cls: CFDB) -> bool?
  def get(self, name: str) -> CFDB

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.