{"id":"chatcmpl-2062ec16-2314-4772-a264-6f987407689d","created":1745811058,"model":"gemini-flash","object":"chat.completion","system_fingerprint":null,"choices":[{"finish_reason":"stop","index":0,"message":{"content":"I am a large language model, trained by Google.\n","role":"assistant","tool_calls":null,"function_call":null}}],"usage":{"completion_tokens":12,"prompt_tokens":5,"total_tokens":17,"completion_tokens_details":null,"prompt_tokens_details":{"audio_tokens":null,"cached_tokens":null}},"vertex_ai_grounding_metadata":[],"vertex_ai_safety_results":[],"vertex_ai_citation_metadata":[]}
最後に
LiteLLM Proxy で Gemini flash を動作させる方法を紹介しました
これで Open WebUI のモデルを簡単に変更することができます
RuntimeError: MPS backend out of memory (MPS allocated: 14.61 GB, other allocations: 3.03 GB, max allowed: 18.13 GB). Tried to allocate 630.00 MB on private pool. Use PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable upper limit for memory allocations (may cause system failure).
デフォルトだと使用するメモリに制限があるのでメモリの制限をしないようにして起動すれば OK です
PYTORCH_MPS_HIGH_WATERMARK_RATIO=0 ./webui.sh
最後に
stable-diffusion-webui-forge で SVD をしてみました
SVD は image -> video はできますが text -> video はまだできないようです
{"id":"chatcmpl-BOZAENZRJ1j3WErgssAmUj41gcl16","created":1745194742,"model":"gpt-4o-2024-08-06","object":"chat.completion","system_fingerprint":"fp_ee1d74bde0","choices":[{"finish_reason":"stop","index":0,"message":{"content":"I am based on OpenAI's GPT-4 architecture, which is a type of large language model (LLM) designed for understanding and generating human-like text.","role":"assistant","tool_calls":null,"function_call":null}}],"usage":{"completion_tokens":34,"prompt_tokens":12,"total_tokens":46,"completion_tokens_details":{"accepted_prediction_tokens":0,"audio_tokens":0,"reasoning_tokens":0,"rejected_prediction_tokens":0},"prompt_tokens_details":{"audio_tokens":0,"cached_tokens":0}},"service_tier":null,"prompt_filter_results":[{"prompt_index":0,"content_filter_results":{"hate":{"filtered":false,"severity":"safe"},"self_harm":{"filtered":false,"severity":"safe"},"sexual":{"filtered":false,"severity":"safe"},"violence":{"filtered":false,"severity":"safe"}}}]}
* *[16:28:35]* You :you:
Create another Message instance and call the say method.
#+BEGIN_SRC python
from my_libs.util import Message
def main():
# Create an instance of the Message class
msg = Message()
# Call the say method with keyword arguments
try:
msg.say(text="Hello, World!", sender="user@example.com", recipient="recipient@example.com")
except ValueError:
print("An error occurred while executing the say method.")
if __name__ == "__main__":
main()
#+END_SRC
** *[16:28:39]* Copilot(gpt-4o) :copilot:
*** Create another Message instance and call the ~say~ method
To create another instance of the ~Message~ class and call the ~say~ method, you can follow the example below:
#+BEGIN_SRC python
from my_libs.util import Message
def main():
# Create the first instance of the Message class
msg1 = Message()
# Call the say method for the first instance
try:
msg1.say(text="Hello, World!", sender="user@example.com", recipient="recipient@example.com")
except ValueError:
print("An error occurred while executing the say method for msg1.")
# Create another instance of the Message class
msg2 = Message()
# Call the say method for the second instance
try:
msg2.say(text="Goodbye, World!", sender="admin@example.com", recipient="user@example.com")
except ValueError:
print("An error occurred while executing the say method for msg2.")
if __name__ == "__main__":
main()
#+END_SRC
*** Explanation
+ The code creates two separate instances of the ~Message~ class: ~msg1~ and ~msg2~.
+ The ~say~ method is called on each instance with different arguments.
+ Error handling is included using ~try~ and ~except~ blocks to catch any ~ValueError~ exceptions that may occur during the execution of the ~say~ method.
* ╭──── Chat Input ────╮ :copilotChatInput:
* *[11:06:32]* You :you:
Please provide a sample python code that uses the Message class.
** *[11:06:34]* Copilot(gpt-4o) :copilot:
*** Sample Python Code Using the Message Class
Here is a sample Python code that demonstrates the use of the `Message` class from the `email.message` module. This example creates an email message, sets its headers, and adds content.
#+BEGIN_SRC python
from email.message import EmailMessage
def create_email():
# Create an instance of the EmailMessage class
msg = EmailMessage()
# Set the email headers
msg['From'] = 'sender@example.com'
msg['To'] = 'recipient@example.com'
msg['Subject'] = 'Sample Email Subject'
# Add the email content
msg.set_content('This is the plain text content of the email.')
# Add an HTML version of the content
msg.add_alternative("""
<html>
<body>
<h1>This is the HTML content of the email.</h1>
<p>It includes <b>bold</b> and <i>italic</i> text.</p>
</body>
</html>
""", subtype='html')
return msg
# Example usage
if __name__ == "__main__":
email_message = create_email()
print(email_message)
#+END_SRC
*** Key Points
+ The `EmailMessage` class is part of Python's built-in `email` module.
+ The `set_content` method is used to add plain text content.
+ The `add_alternative` method is used to add an HTML version of the email content.
+ Headers like ~From~, ~To~, and ~Subject~ are set using dictionary-like syntax.
import time
classMessage:defsay(self,**kwargs):print("Start say")print(kwargs)
time.sleep(10)raise ValueError()# print("End say")
そして更に質問します
するとコンテキストとして追加したクラスをちゃんと使って修正してくれます
* *[11:07:47]* You :you:
Use the Message class in my_libs/utils.py
** *[11:07:48]* Copilot(gpt-4o) :copilot:
*** Sample Code Using the ~Message~ Class in ~my_libs/utils.py~
Below is an example of how to use the ~Message~ class from your provided code in ~my_libs/utils.py~.
#+BEGIN_SRC python
from my_libs.utils import Message
def main():
# Create an instance of the Message class
msg = Message()
# Call the say method with keyword arguments
try:
msg.say(text="Hello, World!", sender="user@example.com", recipient="recipient@example.com")
except ValueError:
print("An error occurred while executing the say method.")
if __name__ == "__main__":
main()
#+END_SRC
*** Explanation
+ The ~Message~ class is imported from ~my_libs/utils.py~.
+ An instance of the ~Message~ class is created using ~msg = Message()~.
+ The ~say~ method is called with keyword arguments like ~text~, ~sender~, and ~recipient~.
+ A ~try-except~ block is used to handle the ~ValueError~ raised by the ~say~ method.
* *[11:11:04]* You :you:
Add a field to the Message class to manage the message body.
** *[11:11:06]* Copilot(gpt-4o) :copilot:
*** Updated ~Message~ Class with a Field for the Message Body
Below is the updated ~Message~ class with a new field to manage the message body.
#+BEGIN_SRC python
import time
class Message:
def __init__(self, body=""):
"""
Initialize the Message class with an optional body field.
"""
self.body = body
def say(self, **kwargs):
"""
Print the message body and additional keyword arguments.
"""
print("Start say")
print("Message Body:", self.body)
print("Additional Arguments:", kwargs)
time.sleep(10)
raise ValueError()
# print("End say")
#+END_SRC
*** Explanation of Changes
+ A new field ~body~ is added to the ~Message~ class, initialized in the constructor (~__init__~).
+ The ~say~ method now prints the value of the ~body~ field along with the additional keyword arguments.
*** Example Usage
Here is an example of how to use the updated ~Message~ class:
#+BEGIN_SRC python
from my_libs.utils import Message
def main():
# Create an instance of the Message class with a custom body
msg = Message(body="This is the message body.")
# Call the say method with keyword arguments
try:
msg.say(sender="user@example.com", recipient="recipient@example.com")
except ValueError:
print("An error occurred while executing the say method.")
if __name__ == "__main__":
main()
#+END_SRC
*** Key Points
+ The ~body~ field allows you to store and manage the message content directly within the ~Message~ class.
+ The ~say~ method now includes the ~body~ field in its output for better context.
* ╭──── Chat Input ────╮ :copilotChatInput:
YOUR_TOKEN の部分には Github から取得したトークンを入力してください
MCP サーバはほぼすべての Github API を使用するので権限は多めに設定するのがいいかなと思います
MCP サーバに呼び出させたい API だけ権限を付与するのもありです
このように記載すると Claude 起動時に docker を使って自動で MCP サーバを起動してくれます
動作確認
初回起動時は Claude から docker へのアクセス権限がなく失敗するので許可してから再起動しましょう
MCP サーバが docker で起動していれば OK です
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b725ec0e9a8 ghcr.io/github/github-mcp-server "./github-mcp-server…" 1 second ago Up 1 second amazing_lumiere
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: xxxx-xxxx
Press Enter to open github.com in your browser...
! Failed opening a web browser at https://github.com/login/device
exec: "xdg-open,x-www-browser,www-browser,wslview": executable file not found in $PATH
Please try entering the URL in your browser manually
? Authentication complete.
- gh config set -h github.com git_protocol https
? Configured git protocol
! Authentication credentials saved in plain text
? Logged in as username