-
Notifications
You must be signed in to change notification settings - Fork 23
Connector Implementation & Inheritance Ollama #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Connector Implementation & Inheritance Ollama #456
Conversation
#455 (comment) |
개요replacement of #455
백로그
커버해야하는 경계값은?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! 먼저 로컬 머신에서 기동하는 부분을 테스트했습니다.
확인해보니 몇가지 상의할 부분이 있었습니다.
첫째로 Model의 경우 Ollama의 네이밍 컨벤션을 고려해 유효성 검사 로직이 필요할까요?
제 생각에는 차후에 문서에 잘 반영해두면 될 것 같은데 어떠실까요?
둘째로 테스트에서 커버할 경계값을 더 추가하면 좋겠습니다.
현재는 공백, null에 대해서 다루고 있습니다.
Model의 경우에는 위에서 유효성 검사 로직 추가여부에 따라 달라질 것 같고,
Uri를 잘못된 형식으로 전달한 경우도 테스트해도 좋을 것 같습니다.
그외에 테스트 컨벤션을 잘 반영해주셨습니다. 😎😎
값 앞뒤로 trailing 공백에 대한 부분은 settings.BaseUrl!.Trim()) == true 부분에서 공백이 없어지기에 추가하지 않는다고 판단해서 추가하지 않았습니다 baseurl에 url 포맷이 아닌경우에 대한 경계값은 EnsureLanguageModelSettingsValid 메서드는 단순히string.IsNullOrWhiteSpace만 체크하기에 GetChatClientAsync에서 경우에만 추가하였습니다! |
로컬 컨테이너 배포시
👉 그래서 해야할 일은
Azure 클라우드 배포시
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트코드 잘 확인했습니다!
다른 부분을 본 다음 돌아와서 다시 전체적으로 확인해보시죠.
그전에 호스트 머신의 Ollama를 사용하기 위한 설정방법을 문서에 추가하고,
Azure 배포시 발생하는 오류를 해결해야합니다.
저도 방법을 찾아보고 코멘트 등으로 공유드리겠습니다.
말씀하신 내용 확인했습니다! 정리하자면
필요한 과정: 컨테이너 동시 실행 설정: 애플리케이션 컨테이너와 Ollama 컨테이너를 한 번에 실행하고 관리할 수 있도록 docker-compose.yml 같은 파일을 작성 모델 데이터 유지를 위한 볼륨 설정: Ollama가 모델 파일을 매번 새로 내려받지 않도록, 컨테이너 외부의 특정 경로와 컨테이너 내부의 모델 저장 경로를 볼륨으로 연결 컨테이너 간 통신 설정: 애플리케이션에서는 http://ollama:11434와 같이 컨테이너 이름을 사용해 Ollama 서비스에 접근하도록 설정 |
네 맞습니다~ 제 의견은 컨테이너화하고, Container Apps로 배포, 이후 서버리스 GPU를 사용하는 것입니다. |
제가 알고 있는 토대로 host.docker.internal:11434 방식으로 문서 추가했습니다. ollama 쪽 환경변수로 함은 $env:OLLAMA_HOST = "0.0.0.0:11434" 쪽을 말하시는것 같아서 이 부분 추가했는데 다른 부분일까요? |
네 이부분 말씀드린게 맞습니다. 현재 단계에서는 Ollama는 Azure 배포를 하지 않는데, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다음 두가지 반영해주셔요!
1) bicep으로 배포시 오류나는 것 확인하고 수정방법 제안.
우리는 ollama를 사용하는데, 아래 구문에서 github models 관련 값이 null이어서 오류발생함! 값 유무를 보고 분기 처리해야할 것 같음.
https://github.com/aliencube/open-chat-playground/pull/456/files#diff-e800ed75064b740be458a572b91420b94ca6743a609c7318facf638f60c7028bL141
OpenAI쪽 이슈에서는 이렇게 처리했군요!
https://github.com/aliencube/open-chat-playground/pull/429/files#diff-e800ed75064b740be458a572b91420b94ca6743a609c7318facf638f60c7028bR150
2) Ollama baseurl도 처리
나중에 ollama를 Azure에서 구동할 예정이라서, 문서에 https://{{OLLAMA_PLACEHOLDER}}:11434
이런 느낌으로 연결 URL 넘겨주는 방법도 포함하고, bicep에도 해당 변수를 처리할 수 있도록 수정해주셔요.
리뷰 준비되면 댓글로 변경사항 간략히 알려주세요 전체적으로 잘 동작하는지 확인되면, |
|
conflict 해결해서 push 했습니다! |
@donghyeon639 아직 conflict가 남아있어서 한번더 확인해주셔욥 |
@tae0y 올리신 리뷰사항들보고 수정했습니다! |
넵 이제 코드 스타일과 |
말씀하신 사항 수정했습니다! |
# bash/zsh | ||
export OLLAMA_HOST=0.0.0.0:11434 | ||
ollama serve | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinyoo 저스틴님! Ollama Connector가 거의 다 마무리 되었습니다. 이번 PR은 이렇게 마무리하고, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@donghyeon639 @tae0y 우선 이정도로 문서 관련 리뷰 코멘트 남겨뒀습니다. 찬찬히 읽어보시고 다른 문서들과 일관성을 맞춰주세요.
ollama pull llama3.2 | ||
# Verify Ollama is accessible | ||
curl http://localhost:11434/api/version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curl
명령어는 파워셸(윈도우OS)에서는 동작하지 않습니다. 따라서, 파워셸용 Invoke-RestMethod
커맨드로도 돌아갈 수 있게 해야 합니다.
다른 문서 보시면 이런 경우 # bash/zsh
와 # PowerShell
을 구분지어 놓은 것을 볼 수 있을 겁니다.
docs/ollama.md
Outdated
```powershell | ||
# PowerShell (Windows) | ||
$env:OLLAMA_HOST = "0.0.0.0:11434" | ||
# Start Ollama service | ||
ollama serve | ||
``` | ||
|
||
```bash | ||
# bash/zsh | ||
export OLLAMA_HOST=0.0.0.0:11434 | ||
ollama serve | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
순서는 # bash/zsh
다음에 # PowerShell
로 다른 문서와 일관성을 맞춰주세요.
docs/ollama.md
Outdated
--model qwen | ||
``` | ||
> **NOTE**: Use `host.docker.internal:11434` to connect to Ollama running on the host machine from inside the container. Make sure `OLLAMA_HOST=0.0.0.0:11434` is set on the host. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 OLLAMA_HOST=0.0.0.0:11434
꼭 호스트 머신에서 해 줘야 하나요? 안하면 어떻게 되나요? 허깅페이스 돌릴 땐 이런 얘기가 없었던 것 같은데?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
설정하지 않으면 외부 앱에서 Ollama에 접근하지 못합니다.
Ollama의 고질적인 문제인데, 앱 자체가 127.0.0.1
위에 떠있어서 다른 네트워크 위의 요청을 듣지 못해서요.
공식 문서에서도 운영체제별로 0.0.0.0
위에 서빙해서 네트워크 이슈를 해결하라고 가이드할 정도입니다.
https://docs.ollama.com/faq#how-do-i-configure-ollama-server%3F
최근에는 앱이 업데이트되며 GUI 설정 메뉴에서 expose ollama to the network
도 활성화해줘야해요.
이런 네트워크 연결 이슈 해결방법 자체는 Ollama쪽에서도 계속해서 업데이트가 될것 같으니,
저희 문서에서는 제외하고 Ollama 공식 문서를 참고하라 정도만 남겨도 좋겠네요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇다면, 저 OLLAMA_HOST=0.0.0.0:11434
관련 내용 및 Ollama UI 설정 관련해서는 우리 문서에서는 그쪽으로 링크를 걸어주는 게 낫겠네요. 우리는 host.docker.internal:11434
이 정도만 언급해도 충분할 듯.
@name-of-okja 혹시 허깅페이스 설정할 때 이 내용도 함께 설정하셨나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추가로
widnwos에 ollama를 설치하고 별도로 OLLAMA_HOST 설정을 안하고 실행시에도 문제 없이 동작 했습니다..!
infra/resources.bicep
Outdated
ollamaModel != '' ? [ | ||
{ | ||
name: 'Ollama__Model' | ||
value: ollamaModel | ||
} | ||
] : [], | ||
ollamaBaseUrl != '' ? [ | ||
{ | ||
name: 'Ollama__BaseUrl' | ||
value: ollamaBaseUrl | ||
} | ||
] : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
별거 아니긴 한데, 보통 우리가 base URL 다음 model을 가져가는 순서를 쓰니까 그 순서를 맞춰볼까요?
"ollamaModel": { | ||
"value": "${OLLAMA_MODEL}" | ||
}, | ||
"ollamaBaseUrl": { | ||
"value": "${OLLAMA_BASE_URL}" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 마찬가지
```bash | ||
dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- --connector-type Ollama --model llama3.2 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 문서 - docs/github-models.md
, docs/hugging-face.md
, docs/openai.md
파일과 같이 일관성을 맞춰 주세요.
```bash | ||
# bash/zsh - from locally built container | ||
docker run -i --rm -p 8080:8080 \ | ||
openchat-playground:latest \ | ||
--connector-type Ollama \ | ||
--base-url http://host.docker.internal:11434 \ | ||
``` | ||
|
||
```powershell | ||
# PowerShell - from locally built container | ||
docker run -i --rm -p 8080:8080 openchat-playground:latest ` | ||
--connector-type Ollama ` | ||
--base-url http://host.docker.internal:11434 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bash/zsh 커맨드와 파워셸 커맨드가 뭔가 일관성이 맞지 않죠? 파워셸처럼 맞춰보세요.
```bash | ||
# bash/zsh - from locally built container | ||
docker run -i --rm -p 8080:8080 \ | ||
openchat-playground:latest \ | ||
--connector-type Ollama \ | ||
--base-url http://host.docker.internal:11434 \ | ||
--model qwen | ||
``` | ||
|
||
```powershell | ||
# PowerShell - from locally built container (with a different model) | ||
docker run -i --rm -p 8080:8080 openchat-playground:latest ` | ||
--connector-type Ollama ` | ||
--base-url http://host.docker.internal:11434 ` | ||
--model qwen | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 마찬가지
docs/ollama.md
Outdated
1. Pull the model you want to use. Replace `{{MODEL_NAME}}` with your desired model. | ||
|
||
```bash | ||
# Example: Pull llama3.2 model | ||
ollama pull llama3.2 | ||
# Or pull other models | ||
ollama pull mistral | ||
ollama pull phi3 | ||
ollama pull qwen | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 어디에도 {{MODEL_NAME}}
은 없습니다.
docs/ollama.md
Outdated
1. Configure Ollama to accept connections from containers. | ||
|
||
```powershell | ||
# PowerShell (Windows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파워셸은 윈도우 환경이 아니어도 돌아갑니다. 따라서 (Windows)
는 불필요합니다.
서버리스 GPU를 써서 Ollama 서버를 운영해야 하는데, 이렇게 하면 사용할 수 있는 지역이 세 개로 확 줄어요. 그래서 이걸 넣는 게 좋을까 고민중... 관련 문서 |
}; | ||
|
||
var chatClient = new OllamaApiClient(config); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요 사이에 요걸 넣어줘야 나중에 자동으로 모델을 pull 땡겨옵니다.
open-chat-playground/src/OpenChat.PlaygroundApp/Connectors/HuggingFaceConnector.cs
Lines 64 to 70 in 5ac25c0
var pulls = chatClient.PullModelAsync(model); | |
await foreach (var pull in pulls) | |
{ | |
Console.WriteLine($"Pull status: {pull!.Status}"); | |
} | |
Console.WriteLine($"The {this._appSettings.ConnectorType} connector created with model: {settings.Model}"); |
infra/main.parameters.json
Outdated
"value": "${HUGGING_FACE_MODEL}" | ||
}, | ||
"ollamaModel": { | ||
"value": "${OLLAMA_MODEL}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"value": "${OLLAMA_MODEL=llama3.2}"
라고 해 줘야 나중에 azd up
실행시킬 때 기본값으로 지정한 모델이 올라갑니다.
#491 PR 머지되면서 컨플릭 생겼습니다. 함께 해결해 주세요. |
@tae0y 올라마 커넥터 수정하면서 테스트 파일에 오류가 생겨서 원인 파악한 후 다시 푸쉬하겠습니다! |
Purpose
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
README updated?
The top-level readme for this repo contains a link to each sample in the repo. If you're adding a new sample did you update the readme?
How to Test
What to Check
Verify that the following are valid
Other Information
https://hub.docker.com/r/ollama/ollama