Skip to content

Commit

Permalink
initialize framework and rewriter module
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenshansilvia committed Feb 5, 2024
1 parent 548da60 commit 249beac
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 17 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Makefile CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Python version
uses: actions/setup-python@v1
with:
python-version: 3.8.18

- name: Install requirements
run: make init

- name: Run check
run: make test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# GoMate
# GoMate

RAG Framework with configurable modules.

[![python](https://img.shields.io/badge/Python-3.8.18-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
![workflow status](https://github.com/gomate-community/rageval/actions/workflows/makefile.yml/badge.svg)
[![pydocstyle](https://img.shields.io/badge/pydocstyle-enabled-AD4CD3)](http://www.pydocstyle.org/en/stable/)
[![PEP8](https://img.shields.io/badge/code%20style-pep8-orange.svg)](https://www.python.org/dev/peps/pep-0008/)

## Installation

```
git clone https://github.com/gomate-community/GoMate.git
```
## Usage

```
git install ...
```
8 changes: 6 additions & 2 deletions gomate/modules/components/HyDE_rewriter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@


class HyDE_rewriter():
"""This is HyDE rewriter."""

def __init__(self):
"""Init the hyde rewriter model"""
pass

def run(query, temperature):
def run(self, query, temperature):
"""Get rewrited querys in runtime"""
# TODO
answer = [['改写后的回答']]
return(answer)
return answer
2 changes: 1 addition & 1 deletion gomate/modules/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from HyDE_rewriter import HyDE_rewriter
from .HyDE_rewriter import HyDE_rewriter
19 changes: 12 additions & 7 deletions gomate/modules/rewriter.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
from .components import HyDE_rewriter

rewriter_list = ['hyde']

class Rewriter():
'''
改写模块,用于理解和优化用户的原始问题。实现包括:
"""改写模块,用于理解和优化用户的原始问题。
实现包括
1. HyDE。用生成式大模型预回答,返回生成的假定答案。
2. ...
'''
"""

def __init__(self, component_name=None):
assert component_name in rewriter_list
"""Init required rewriter according to component name."""
self.rewriter_list = ['hyde']
assert component_name in self.rewriter_list
if component_name == 'hyde':
self.rewriter = HyDE_rewriter()

def run(self, query, temperature=1e-10):
"""Run the required rewriter"""
if query is None:
raise ValueError('原始问题不能为空')
return(self.rewriter.run(query, temperature = temperature))
return self.rewriter.run(query, temperature)
7 changes: 2 additions & 5 deletions tests/build.py → tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""Test building RAG system."""

import sys
sys.path.insert(0, '../src')
import pytest

@pytest.mark.cron
@pytest.mark.skip
def test_build():
'''
xx
'''
pass
return
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest
from gomate.modules import Rewriter
# import os

def test_rewriter():
component_name = 'hyde'
model = Rewriter(component_name = component_name)
query = ['gomate是哪天发布的?','gomate是做什么的?']
answer = model(query)
answer = model.run(query)
assert answer is not None

if __name__ == '__main__':
Expand Down

0 comments on commit 249beac

Please sign in to comment.